From 30a0842aa110ef0b618530676cd1071702f5d987 Mon Sep 17 00:00:00 2001 From: Kim Ravn Hansen Date: Mon, 22 Sep 2025 16:52:15 +0200 Subject: [PATCH] Whambap --- bench.js | 41 +++ frontend/ascii_dungeon_crawler.html | 147 +++++--- frontend/ascii_dungeon_crawler.js | 536 ++++++++++++++++++++++++++++ frontend/ascii_tile_map.js | 89 +++++ frontend/ascrii_window.js | 196 ++++++++++ frontend/vec2.js | 164 +++++++++ 6 files changed, 1130 insertions(+), 43 deletions(-) create mode 100755 bench.js create mode 100755 frontend/ascii_dungeon_crawler.js create mode 100755 frontend/ascii_tile_map.js create mode 100755 frontend/ascrii_window.js create mode 100755 frontend/vec2.js 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