Files
bworld/tests/worldgen_bench.ts
T
2026-10-11 01:26:51 -03:00

28 lines
1.1 KiB
TypeScript

// how long generating chunks takes, on one thread. moving the terrain from code to data was held to 15% slower here,
// and cost about 9% (144.5 to 157.7 ms on the machine it was measured on). deno task bench
import { generate_raw_chunk } from "$/common/generation.ts";
import { test_game } from "./helpers.ts";
const SEED = "bench-seed";
const { game } = await test_game("mods", undefined, SEED);
const { block_ids, worldgen, default_values } = game.world;
Deno.bench("generate 1 chunk", () => {
for (let i = 0; i < 1; i++) {
generate_raw_chunk(i * 37 - 300, i * 23 - 180, SEED, block_ids, worldgen, default_values);
}
});
Deno.bench("generate 4 chunks", () => {
for (let i = 0; i < 4; i++) {
generate_raw_chunk(i * 37 - 300, i * 23 - 180, SEED, block_ids, worldgen, default_values);
}
});
// the same 16 chunks every time, from ocean to mountains, so runs can be compared. a sixteenth of it is a chunk
Deno.bench("generate 16 chunks", () => {
for (let i = 0; i < 16; i++) {
generate_raw_chunk(i * 37 - 300, i * 23 - 180, SEED, block_ids, worldgen, default_values);
}
});