Skip to content

ci: merge staging to master #14

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

Merged
merged 2 commits into from
Apr 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "exec"
version = "1.0.0"
version = "1.0.1"
authors = ["Brian Botha <[email protected]>"]
license-file = "LICENSE"
edition = "2021"
Expand Down
26 changes: 26 additions & 0 deletions benches/exec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import path from 'node:path';
import url from 'node:url';
import b from 'benny';
import { suiteCommon } from './utils/index.js';

const filePath = url.fileURLToPath(import.meta.url);

async function main() {
const summary = await b.suite(
path.basename(filePath, path.extname(filePath)),
b.add('stub', () => {
1 + 1;
}),
...suiteCommon,
);
return summary;
}

if (import.meta.url.startsWith('file:')) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
void main();
}
}

export default main;
54 changes: 54 additions & 0 deletions benches/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env tsx

import fs from 'node:fs';
import path from 'node:path';
import url from 'node:url';
import si from 'systeminformation';
import { benchesPath } from './utils/utils.js';
import exec from './exec.js';

async function main(): Promise<void> {
await fs.promises.mkdir(path.join(benchesPath, 'results'), {
recursive: true,
});
await exec();
const resultFilenames = await fs.promises.readdir(
path.join(benchesPath, 'results'),
);
const metricsFile = await fs.promises.open(
path.join(benchesPath, 'results', 'metrics.txt'),
'w',
);
let concatenating = false;
for (const resultFilename of resultFilenames) {
if (/.+_metrics\.txt$/.test(resultFilename)) {
const metricsData = await fs.promises.readFile(
path.join(benchesPath, 'results', resultFilename),
);
if (concatenating) {
await metricsFile.write('\n');
}
await metricsFile.write(metricsData);
concatenating = true;
}
}
await metricsFile.close();
const systemData = await si.get({
cpu: '*',
osInfo: 'platform, distro, release, kernel, arch',
system: 'model, manufacturer',
});
await fs.promises.writeFile(
path.join(benchesPath, 'results', 'system.json'),
JSON.stringify(systemData, null, 2),
);
}

if (import.meta.url.startsWith('file:')) {
const modulePath = url.fileURLToPath(import.meta.url);
if (process.argv[1] === modulePath) {
void main();
}
}

export default main;
1 change: 1 addition & 0 deletions benches/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './utils.js';
66 changes: 66 additions & 0 deletions benches/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import fs from 'fs';
import path from 'path';
import url from 'node:url';
import b from 'benny';
import { codeBlock } from 'common-tags';
import packageJson from '../../package.json';

const benchesPath = path.dirname(
path.dirname(url.fileURLToPath(import.meta.url)),
);

const suiteCommon = [
b.cycle(),
b.complete(),
b.save({
file: (summary) => summary.name,
folder: path.join(benchesPath, 'results'),
version: packageJson.version,
details: true,
}),
b.save({
file: (summary) => summary.name,
folder: path.join(benchesPath, 'results'),
version: packageJson.version,
format: 'chart.html',
}),
b.complete((summary) => {
const filePath = path.join(
benchesPath,
'results',
summary.name + '_metrics.txt',
);
fs.writeFileSync(
filePath,
codeBlock`
# TYPE ${summary.name}_ops gauge
${summary.results
.map(
(result) =>
`${summary.name}_ops{name="${result.name}"} ${result.ops}`,
)
.join('\n')}

# TYPE ${summary.name}_margin gauge
${summary.results
.map(
(result) =>
`${summary.name}_margin{name="${result.name}"} ${result.margin}`,
)
.join('\n')}

# TYPE ${summary.name}_samples counter
${summary.results
.map(
(result) =>
`${summary.name}_samples{name="${result.name}"} ${result.samples}`,
)
.join('\n')}
` + '\n',
);
// eslint-disable-next-line no-console
console.log('\nSaved to:', path.resolve(filePath));
}),
];

export { benchesPath, suiteCommon };
Loading
Loading