-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: performance builtin support (#150)
- Loading branch information
1 parent
8995b35
commit 5197559
Showing
7 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { ok, strictEqual } from 'node:assert'; | ||
|
||
export const source = ` | ||
export function run () { | ||
performance.now(); | ||
}; | ||
`; | ||
|
||
export const disableFeatures = ['clocks']; | ||
|
||
export async function test (run) { | ||
try { | ||
const { stdout, stderr } = await run(); | ||
ok(false); | ||
} catch { | ||
// performance builtin just panics | ||
// (yes we can and should do better...) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ok, strictEqual } from 'node:assert'; | ||
|
||
export const source = ` | ||
export function run () { | ||
const start = performance.now(); | ||
let previous = 0, cur = 1; | ||
for (let i = 1; i < 1000; i++) { | ||
const tmp = cur; | ||
cur = previous + cur; | ||
previous = tmp; | ||
} | ||
const end = performance.now(); | ||
console.log('Calculated fib 1000: ' + cur); | ||
console.error((end - start) + ' ms'); | ||
}; | ||
`; | ||
|
||
export async function test (run) { | ||
const { stdout, stderr } = await run(); | ||
strictEqual(stdout, 'Calculated fib 1000: 4.346655768693743e+208\n'); | ||
|
||
ok(stderr.includes(' ms')); | ||
const time = Number(stderr.split(' ms')[0]); | ||
// TODO: fix back to half a millisecond when Weval fix is added | ||
if (time > 3) { | ||
throw new Error('took more than half a millisecond - ' + time + ' ms'); | ||
} | ||
} |