Skip to content

Commit 62c0328

Browse files
committed
bench/ffi: update runners
1 parent ad0dc92 commit 62c0328

File tree

5 files changed

+14
-57
lines changed

5 files changed

+14
-57
lines changed

bench/ffi/sqlite.bun.ts

+4-19
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,8 @@ function run(): number[] {
155155
return result;
156156
}
157157

158-
// console.log(`result: ${run()}`);
159-
160-
// based on https://github.com/littledivy/blazing-fast-ffi-talk/blob/main/bench.mjs
161-
const total = 10;
162-
const runs = 100_000;
163-
164-
let sum = 0;
165-
const bench = () => {
166-
const start = performance.now();
167-
for (let i = 0; i < runs; i++) run();
168-
const elapsed = Math.floor(performance.now() - start);
169-
const rate = Math.floor(runs / (elapsed / 1000));
170-
sum += rate;
171-
};
172-
173-
for (let i = 0; i < total; i++) {
174-
bench();
175-
}
158+
const runs = 10_000;
159+
const start = performance.now();
160+
for (let i = 0; i < runs; i++) run();
176161

177-
console.log(sum / total);
162+
console.log(((performance.now() - start)).toFixed(10));

bench/ffi/sqlite.deno.ts

+4-17
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,8 @@ function run(): number[] {
144144
return result;
145145
}
146146

147-
// console.log(`result: ${run()}`);
148-
149-
// based on https://github.com/littledivy/blazing-fast-ffi-talk/blob/main/bench.mjs
150-
const total = 10;
151-
const runs = 100_000;
152-
153-
let sum = 0;
154-
const bench = () => {
155-
const start = performance.now();
156-
for (let i = 0; i < runs; i++) run();
157-
const elapsed = Math.floor(performance.now() - start);
158-
const rate = Math.floor(runs / (elapsed / 1000));
159-
sum += rate;
160-
};
161-
162-
for (let i = 0; i < total; i++) bench();
147+
const runs = 10_000;
148+
const start = performance.now();
149+
for (let i = 0; i < runs; i++) run();
163150

164-
console.log(sum / total);
151+
console.log(((performance.now() - start)).toFixed(10));

bench/ffi/sqlite.porf.ts

+4-19
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,8 @@ const run = (): number[] => {
136136
return result;
137137
};
138138

139-
// Porffor.print(run()); Porffor.printStatic('\n');
140-
141-
// based on https://github.com/littledivy/blazing-fast-ffi-talk/blob/main/bench.mjs
142-
const total = 10;
143-
const runs = 100_000;
144-
145-
let sum = 0;
146-
const bench = () => {
147-
const start = performance.now();
148-
for (let i = 0; i < runs; i++) run();
149-
const elapsed = Math.floor(performance.now() - start);
150-
const rate = Math.floor(runs / (elapsed / 1000));
151-
sum += rate;
152-
};
153-
154-
for (let i = 0; i < total; i++) {
155-
bench();
156-
}
139+
const runs = 10_000;
140+
const start = performance.now();
141+
for (let i = 0; i < runs; i++) run();
157142

158-
console.log(sum / total);
143+
console.log(((performance.now() - start)).toFixed(10));

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "porffor",
33
"description": "An ahead-of-time JavaScript compiler",
4-
"version": "0.56.2",
4+
"version": "0.56.3",
55
"author": "Oliver Medhurst <[email protected]>",
66
"license": "MIT",
77
"scripts": {},

runner/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
import fs from 'node:fs';
3-
globalThis.version = '0.56.2';
3+
globalThis.version = '0.56.3';
44

55
// deno compat
66
if (typeof process === 'undefined' && typeof Deno !== 'undefined') {

0 commit comments

Comments
 (0)