From 9afad9e0548508a833146a6a9f8515fd99815a0d Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Sun, 29 Dec 2019 13:00:09 +0000 Subject: [PATCH] node tests: Add commented-out benchmarks for Dict. The benchmark is commented out. It takes only a few milliseconds to run, so there may be no reason not to always run it. It doesn't test correctness, so it would arguably inflate line coverage, but set/get are obviously covered elsewhere. --- frontend_tests/node_tests/dict.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/frontend_tests/node_tests/dict.js b/frontend_tests/node_tests/dict.js index 1738f56c7d..d404a9ea85 100644 --- a/frontend_tests/node_tests/dict.js +++ b/frontend_tests/node_tests/dict.js @@ -171,6 +171,27 @@ run_test('num_items', () => { assert.equal(d.num_items(), 1); }); +/* +run_test('benchmark', () => { + const d = new Dict(); + const n = 5000; + const t1 = new Date().getTime(); + + _.each(_.range(n), (i) => { + d.set(i, i); + }); + + _.each(_.range(n), (i) => { + d.get(i, i); + }); + + const t2 = new Date().getTime(); + const elapsed = t2 - t1; + console.log('elapsed (milli)', elapsed); + console.log('per (micro)', 1000 * elapsed / n); +}); +*/ + run_test('clear', () => { const d = new Dict();