From b122279ece06a9381e805c6087f130b41616fe3d Mon Sep 17 00:00:00 2001 From: Geo Halkiadakis Date: Fri, 12 Apr 2024 18:31:00 +0300 Subject: added utils folder; added several suplamentary modules --- benchmark/match-str.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'benchmark/match-str.js') diff --git a/benchmark/match-str.js b/benchmark/match-str.js index 7760b4e..fa802c1 100644 --- a/benchmark/match-str.js +++ b/benchmark/match-str.js @@ -1,17 +1,23 @@ -const products = require('../data/products.json'); -const match = require('../pieces/match-util.js'); var microtime = require('microtime'); +const match = require('../utils/match-util.js'); +const memory_usage = require('../utils/mem-usage.js'); + +const products = require('../data/products.json'); -query = 'solokata'; +// memory_usage.report(); -function run() { +// test runner +function run(query) { var f0 = microtime.nowDouble(); - // for(let i = 0 ; i < 100 ; i++) - let result = matchQuery(query); + let result; + // for(let i = 0 ; i < 20 ; i++) + result = matchQuery(query); var f1 = microtime.nowDouble(); + memory_usage.report(); + return { t: f1-f0, q: query, @@ -19,7 +25,7 @@ function run() { } } - +// sumple search implementation function matchQuery(q) { var result = []; @@ -43,4 +49,4 @@ function matchQuery(q) { } -module.exports = { run } \ No newline at end of file +module.exports = { run } -- cgit v1.2.3