Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 1.2.2 to bun-version matrix at workflows #1643

Merged
merged 9 commits into from
Feb 19, 2025
3 changes: 2 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ jobs:
max-parallel: 3
matrix:
bun-version:
- 1.1.43
- 1.4.43
- 1.2.2

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ jobs:
max-parallel: 1
matrix:
bun-version:
- 1.1.43
- 1.4.43
- 1.2.2

steps:
- uses: actions/checkout@v4
Expand Down
25 changes: 23 additions & 2 deletions benchmarks/helpers/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,23 @@ function pathFromStack() {
}
throw new Error('Could not get dirname');
}

function getRuntimeWithVersion() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I implement this
because determine runtime by USER env is bad practic

Copy link
Contributor Author

@kravetsone kravetsone Feb 13, 2025

Choose a reason for hiding this comment

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

before this npm run start:bun will generate results for node@22 (but its Bun results)

// @ts-expect-error
if (typeof Bun !== 'undefined') {
return { RUNTIME: 'bun', RUNTIME_VERSION: process.versions['bun'] };
}

// @ts-expect-error
if (typeof Deno !== 'undefined') {
return { RUNTIME: 'deno', RUNTIME_VERSION: process.versions['deno']};
}

return { RUNTIME: 'node', RUNTIME_VERSION: process.version };
}

const DOCS_DIR = join(pathFromStack().dirpath, '../../docs');
const RUNTIME = process.env.RUNTIME || 'node';
const RUNTIME_VERSION = process.env.RUNTIME_VERSION || process.version;
const { RUNTIME, RUNTIME_VERSION } = getRuntimeWithVersion();
const RUNTIME_FOR_PREVIEW = 'node';
const NODE_VERSION_FOR_PREVIEW = 20;

Expand Down Expand Up @@ -118,6 +132,7 @@ async function runBenchmarks(name: string, cases: BenchmarkCase[]) {
// append results to an existing file or create a new one
function appendResults(results: BenchmarkResult[]) {
const fileName = resultsJsonFilename();
console.log('fileName', fileName, RUNTIME, RUNTIME_VERSION);
const existingResults: BenchmarkResult[] = existsSync(fileName)
? JSON.parse(readFileSync(fileName).toString()).results
: [];
Expand Down Expand Up @@ -163,6 +178,12 @@ function previewSvgFilename() {
}

function getNodeMajorVersion() {
// Hack for bun runtime to include major and minor version
// like 1.2.3 -> 1.2
if (RUNTIME === 'bun') {
return parseFloat(RUNTIME_VERSION);
}

let majorVersion = 0;

majorVersion = parseInt(RUNTIME_VERSION);
Expand Down
11 changes: 6 additions & 5 deletions docs/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as vegaLite from 'vega-lite';
// the first is selected automatically
const NODE_VERSIONS = [23, 22, 21, 20, 19, 18, 16];

const BUN_VERSIONS = [1];
const BUN_VERSIONS = [1.2];

const DENO_VERSIONS = [2];

Expand Down Expand Up @@ -131,7 +131,7 @@ function normalizePartialValues(values: BenchmarkResult[]): BenchmarkResult[] {
}

const nodeVersionRegex = /v([0-9]+)\./;
const bunVersionRegex = /([0-9]+)\./;
const bunVersionRegex = /^(\d+)\.(\d+)\./;
const denoVersionRegex = /([0-9]+)\./;

function getNodeMajorVersionNumber(nodeVersion: string): number {
Expand All @@ -144,14 +144,15 @@ function getNodeMajorVersionNumber(nodeVersion: string): number {
return parseInt(match[1]);
}

function getBunMajorVersionNumber(bunVersion: string): number {
function getBunMajorAndMinorVersionNumber(bunVersion: string): number {
const match = bunVersion.match(bunVersionRegex);

if (!match) {
throw new Error(`Invalid bun version: ${bunVersion}`);
}

return parseInt(match[1]);
// We can use just parseFloat but don't matter
return parseFloat(`${match[1]}.${match[2]}`);
}

function getDenoMajorVersionNumber(denoVersion: string): number {
Expand Down Expand Up @@ -238,7 +239,7 @@ async function graph({
benchmark: [
runtimesOrder.BUN,
BENCHMARKS_ORDER[b.benchmark],
BUN_VERSIONS.indexOf(getBunMajorVersionNumber(b.runtimeVersion)),
BUN_VERSIONS.indexOf(getBunMajorAndMinorVersionNumber(b.runtimeVersion)),
b.runtimeVersion,
b.benchmark,
].join('-'),
Expand Down