diff --git a/bench.js b/bench.js new file mode 100755 index 0000000..8ef5e2a --- /dev/null +++ b/bench.js @@ -0,0 +1,41 @@ +function dataset() { + return new Array(4000).fill().map(() => "fusse".repeat(5)); +} + +const simCount = 100_000; + +const start = Date.now(); + +const target = "not found"; + +for (let sim = 0; sim < simCount; sim++) { + const ds = dataset(); + + // const len = ds.length; + // for (let i = 0; i < len; i++) { + // // pretend to do work on the data elements + // const el = ds[i]; + // if (el === target) { + // console.log("foo"); + // } + // } + + // ds.forEach((el) => { + // if (el === target) { + // console.log("foo"); + // } + // }); + + while (ds.length > 0) { + let el = ds.pop(); + if (el === target) { + console.log("foo"); + } + } +} + +console.log("time: %f msec", Date.now() - start); + +// for-loop : 8568 msec +// .forEach : 8551 msec +// pop() : 8765 msec diff --git a/frontend/ascii_dungeon_crawler.html b/frontend/ascii_dungeon_crawler.html index e823fe4..11cf1a1 100755 --- a/frontend/ascii_dungeon_crawler.html +++ b/frontend/ascii_dungeon_crawler.html @@ -5,30 +5,6 @@ ASCII Dungeon Crawler