Skip to content

Commit

Permalink
Longer benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
PalumboN committed Jan 8, 2025
1 parent db4e5ed commit b324001
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"test:wtest": "mocha --delay -t 10000 -r ts-node/register/transpile-only test/wtest.ts",
"test:printer": "mocha --parallel -r ts-node/register/transpile-only test/printer.test.ts",
"test:parser": "mocha -r ts-node/register/transpile-only test/parser.test.ts",
"test:benchmarks": "mocha -t 100000 -r ts-node/register/transpile-only test/benchmarks.ts",
"test:benchmarks": "mocha -t 999999 -r ts-node/register/transpile-only test/benchmarks.ts",
"lint:fix": "eslint . --fix",
"validate:wollokVersion": "ts-node scripts/validateWollokVersion.ts",
"prepublishOnly": "npm run validate:wollokVersion && npm run build && npm test",
Expand Down
19 changes: 10 additions & 9 deletions test/benchmarks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ describe('Benchmarks', () => {


const time = totalTime / iterations
const deltaError = Math.max(0.1, expectedTime * 0.1) // 0.1 or 10 %
const deltaError = expectedTime * 0.15 // 15 %
restore()

// console.info(`${message} - ${fqn} - ${time} ms (${iterations} iterations)`)
Expand All @@ -38,13 +38,13 @@ describe('Benchmarks', () => {
})
}

benchmark('empty', 0.55)
benchmark('visuals_1', 0.4)
benchmark('visuals_100', 0.3)
benchmark('ticks_1', 0.8)
benchmark('ticks_100', 44)
benchmark('onCollide_1', 0.8)
benchmark('onCollide_100', 44)
benchmark('empty', 3.5)
benchmark('visuals_1', 3.1)
benchmark('visuals_100', 2.6)
benchmark('ticks_1', 7.7)
benchmark('ticks_100', 430)
benchmark('onCollide_1', 7.5)
benchmark('onCollide_100', 440)

})
})
Expand All @@ -58,7 +58,8 @@ async function measure(programFQN: string, message: string): Promise<number> {

interpreter.send(message, game, interpreter.reify(0)) // Fill caches
const startTime = performance.now()
interpreter.send(message, game, interpreter.reify(1))
for (let ms = 1; ms < 10; ms++)

Check warning on line 61 in test/benchmarks.ts

View workflow job for this annotation

GitHub Actions / build

Trailing spaces not allowed

Check warning on line 61 in test/benchmarks.ts

View workflow job for this annotation

GitHub Actions / build

Trailing spaces not allowed
interpreter.send(message, game, interpreter.reify(ms))
const endTime = performance.now()

const elapsedTime = endTime - startTime
Expand Down

1 comment on commit b324001

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmarks
flushEvents
1) empty
2) visuals_1
3) visuals_100
4) ticks_1
5) ticks_100
6) onCollide_1
7) onCollide_100
┌─────────┬───────────────┬─────────────────┬────────────────────┬────────────┐
│ (index) │ message │ fqn │ time │ iterations │
├─────────┼───────────────┼─────────────────┼────────────────────┼────────────┤
│ 0 │ 'flushEvents' │ 'empty' │ 6.130495533332578 │ 30 │
│ 1 │ 'flushEvents' │ 'visuals_1' │ 4.54589123333329 │ 30 │
│ 2 │ 'flushEvents' │ 'visuals_100' │ 4.228001266666494 │ 30 │
│ 3 │ 'flushEvents' │ 'ticks_1' │ 11.84803696666495 │ 30 │
│ 4 │ 'flushEvents' │ 'ticks_100' │ 637.7610027666669 │ 30 │
│ 5 │ 'flushEvents' │ 'onCollide_1' │ 11.211476966670793 │ 30 │
│ 6 │ 'flushEvents' │ 'onCollide_100' │ 675.9710701333286 │ 30 │
└─────────┴───────────────┴─────────────────┴────────────────────┴────────────┘

0 passing (3m)
7 failing

  1. Benchmarks
    flushEvents
    empty:
    AssertionError: expected 6.130495533332578 to be close to 3.5 +/- 0.525
    at Context. (test/benchmarks.ts:37:24)

  2. Benchmarks
    flushEvents
    visuals_1:
    AssertionError: expected 4.54589123333329 to be close to 3.1 +/- 0.46499999999999997
    at Context. (test/benchmarks.ts:37:24)

  3. Benchmarks
    flushEvents
    visuals_100:
    AssertionError: expected 4.228001266666494 to be close to 2.6 +/- 0.39
    at Context. (test/benchmarks.ts:37:24)

  4. Benchmarks
    flushEvents
    ticks_1:
    AssertionError: expected 11.84803696666495 to be close to 7.7 +/- 1.155
    at Context. (test/benchmarks.ts:37:24)

  5. Benchmarks
    flushEvents
    ticks_100:
    AssertionError: expected 637.7610027666669 to be close to 430 +/- 64.5
    at Context. (test/benchmarks.ts:37:24)

  6. Benchmarks
    flushEvents
    onCollide_1:
    AssertionError: expected 11.211476966670793 to be close to 7.5 +/- 1.125
    at Context. (test/benchmarks.ts:37:24)

  7. Benchmarks
    flushEvents
    onCollide_100:
    AssertionError: expected 675.9710701333286 to be close to 440 +/- 66
    at Context. (test/benchmarks.ts:37:24)

Please sign in to comment.