From 7cc18f92e348e5f29bad95647766e8916cc22024 Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 16:34:31 +0200 Subject: [PATCH 01/13] replace `platform` with `os` --- action-types.yml | 2 +- action.yml | 4 +- src/config.ts | 12 ++--- src/extract.ts | 4 +- test/__snapshots__/extract.spec.ts.snap | 68 ++++++++++++------------- test/config.spec.ts | 6 +-- test/extract.spec.ts | 10 ++-- 7 files changed, 53 insertions(+), 53 deletions(-) diff --git a/action-types.yml b/action-types.yml index de67f57..769eaa2 100644 --- a/action-types.yml +++ b/action-types.yml @@ -5,7 +5,7 @@ inputs: type: enum allowed-values: - cargo - platform: + os: type: string output-file-path: type: string diff --git a/action.yml b/action.yml index 3b348ef..2a95b3f 100644 --- a/action.yml +++ b/action.yml @@ -13,8 +13,8 @@ inputs: tool: description: 'Tool to use to get benchmark output. One of "cargo"...' required: true - platform: - description: 'A string describing the platform' + os: + description: 'A string describing the os' required: true output-file-path: description: 'A path to file which contains the benchmark output' diff --git a/src/config.ts b/src/config.ts index 54f0ee7..ad6f037 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,7 +6,7 @@ import * as path from 'path'; export type ToolType = typeof VALID_TOOLS[number]; export interface Config { name: string; - platform: string; + os: string; tool: ToolType; outputFilePath: string; dataOutPath: string; @@ -71,8 +71,8 @@ function validateName(name: string) { } throw new Error('Name must not be empty'); } -function validatePlatform(platform: string) { - if (platform) { +function validatePlatform(os: string) { + if (os) { return; } throw new Error('Platform must not be empty'); @@ -83,10 +83,10 @@ export async function configFromJobInput(): Promise { let outputFilePath: string = core.getInput('output-file-path'); let dataOutPath: string = core.getInput('data-out-path'); const name: string = core.getInput('name'); - const platform: string = core.getInput('platform'); + const os: string = core.getInput('os'); validateName(name); - validatePlatform(platform); + validatePlatform(os); validateToolType(tool); outputFilePath = await validateOutputFilePath(outputFilePath); dataOutPath = await validateDataOutPath(dataOutPath); @@ -96,6 +96,6 @@ export async function configFromJobInput(): Promise { tool, outputFilePath, dataOutPath, - platform, + os, }; } diff --git a/src/extract.ts b/src/extract.ts index fcda046..ba6158d 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -8,7 +8,7 @@ export interface BenchmarkResult { range?: string; unit: string; extra?: string; - platform: string; + os: string; } function extractCargoResult(config: Config, output: string): BenchmarkResult[] { @@ -33,7 +33,7 @@ function extractCargoResult(config: Config, output: string): BenchmarkResult[] { value, range: `± ${range}`, unit: unit, - platform: config.platform, + os: config.os, }); } diff --git a/test/__snapshots__/extract.spec.ts.snap b/test/__snapshots__/extract.spec.ts.snap index d403a75..0fe50c7 100644 --- a/test/__snapshots__/extract.spec.ts.snap +++ b/test/__snapshots__/extract.spec.ts.snap @@ -4,14 +4,14 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output.txt 1 [ { "name": "bench_fib_10", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 24", "unit": "ns/iter", "value": 135, }, { "name": "bench_fib_20", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 755", "unit": "ns/iter", "value": 18149, @@ -23,35 +23,35 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output_units [ { "name": "cmov", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 14", "unit": "cycles/iter", "value": 2835, }, { "name": "cmov2", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 19", "unit": "cycles/iter", "value": 2845, }, { "name": "mov", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 17", "unit": "cycles/iter", "value": 1508, }, { "name": "upload", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 420", "unit": "MS/s", "value": 1911, }, { "name": "download", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 69", "unit": "MS/s", "value": 9001, @@ -63,28 +63,28 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output2.txt [ { "name": "bench_engine_new", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 70126", "unit": "ns/iter", "value": 211834, }, { "name": "bench_engine_new_raw", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 18", "unit": "ns/iter", "value": 197, }, { "name": "bench_engine_new_raw_core", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 31", "unit": "ns/iter", "value": 196, }, { "name": "bench_engine_register_fn", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 82", "unit": "ns/iter", "value": 493, @@ -96,14 +96,14 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output3.txt [ { "name": "bench_fib_10", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 2.21", "unit": "ns/iter", "value": 148.7, }, { "name": "bench_fib_20", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 440.25", "unit": "ns/iter", "value": 18794.12, @@ -115,28 +115,28 @@ exports[`extractData() extracts benchmark output from cargo - criterion_output.t [ { "name": "Create Realm", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 4", "unit": "ns/iter", "value": 329, }, { "name": "Symbols (Execution)", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 47", "unit": "ns/iter", "value": 3268, }, { "name": "For loop (Execution)", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 123", "unit": "ns/iter", "value": 12314, }, { "name": "Fibonacci (Execution)", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 10166", "unit": "ns/iter", "value": 1672496, @@ -148,14 +148,14 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp [ { "name": "bench_fib_10", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 24", "unit": "ns/iter", "value": 135, }, { "name": "bench_fib_20", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 755", "unit": "ns/iter", "value": 18149, @@ -167,35 +167,35 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp [ { "name": "cmov", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 14", "unit": "cycles/iter", "value": 2835, }, { "name": "cmov2", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 19", "unit": "cycles/iter", "value": 2845, }, { "name": "mov", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 17", "unit": "cycles/iter", "value": 1508, }, { "name": "upload", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 420", "unit": "MS/s", "value": 1911, }, { "name": "download", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 69", "unit": "MS/s", "value": 9001, @@ -207,28 +207,28 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp [ { "name": "bench_engine_new", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 70126", "unit": "ns/iter", "value": 211834, }, { "name": "bench_engine_new_raw", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 18", "unit": "ns/iter", "value": 197, }, { "name": "bench_engine_new_raw_core", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 31", "unit": "ns/iter", "value": 196, }, { "name": "bench_engine_register_fn", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 82", "unit": "ns/iter", "value": 493, @@ -240,14 +240,14 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp [ { "name": "bench_fib_10", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 2.21", "unit": "ns/iter", "value": 148.7, }, { "name": "bench_fib_20", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 440.25", "unit": "ns/iter", "value": 18794.12, @@ -259,28 +259,28 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - criterion_ [ { "name": "Create Realm", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 4", "unit": "ns/iter", "value": 329, }, { "name": "Symbols (Execution)", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 47", "unit": "ns/iter", "value": 3268, }, { "name": "For loop (Execution)", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 123", "unit": "ns/iter", "value": 12314, }, { "name": "Fibonacci (Execution)", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "range": "± 10166", "unit": "ns/iter", "value": 1672496, diff --git a/test/config.spec.ts b/test/config.spec.ts index 8621f08..7a677db 100644 --- a/test/config.spec.ts +++ b/test/config.spec.ts @@ -34,7 +34,7 @@ describe('configFromJobInput()', function () { tool: 'cargo', 'output-file-path': 'out.txt', 'data-out-path': 'test.txt', // TODO - platform: 'any', + os: 'any', }; const validationTests: Array<{ @@ -72,13 +72,13 @@ describe('configFromJobInput()', function () { interface ExpectedResult { name: string; tool: string; - platform: string; + os: string; } const defaultExpected: ExpectedResult = { name: 'Benchmark', tool: 'cargo', - platform: 'platform', + os: 'os', }; const returnedConfigTests: Array<{ diff --git a/test/extract.spec.ts b/test/extract.spec.ts index c5fe36e..3d5eedf 100644 --- a/test/extract.spec.ts +++ b/test/extract.spec.ts @@ -36,7 +36,7 @@ describe('extractData()', function () { }); const outputFilePath = path.join(__dirname, 'data', 'extract', test.file); const config = { - platform: 'ubuntu-latest', + os: 'ubuntu-latest', tool: test.tool, outputFilePath, } as Config; @@ -49,7 +49,7 @@ describe('extractData()', function () { it('raises an error on unexpected tool', async function () { const config = { - platform: 'ubuntu-latest', + os: 'ubuntu-latest', tool: 'foo' as any, outputFilePath: path.join(__dirname, 'data', 'extract', 'cargo_output_units.txt'), } as Config; @@ -58,7 +58,7 @@ describe('extractData()', function () { it('raises an error when output file is not readable', async function () { const config = { - platform: 'ubuntu-latest', + os: 'ubuntu-latest', tool: 'cargo', outputFilePath: 'path/does/not/exist.txt', } as Config; @@ -67,7 +67,7 @@ describe('extractData()', function () { it('raises an error when no output found', async function () { const config = { - platform: 'ubuntu-latest', + os: 'ubuntu-latest', tool: 'cargo', outputFilePath: path.join(__dirname, 'data', 'extract', 'invalid.txt'), } as Config; @@ -109,7 +109,7 @@ describe('localWriteBenchmark()', function () { const outputFilePath = path.join(__dirname, 'data', 'extract', test.file); const dataOutPath = 'test.txt'; // TODO: tempfile const config = { - platform: 'ubuntu-latest', + os: 'ubuntu-latest', tool: test.tool, outputFilePath, dataOutPath, From 5c47e69cc4dfb11265dcb3b65bbeef2a55aa87e3 Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 16:42:34 +0200 Subject: [PATCH 02/13] add test for new metadata format --- .../criterion_output_with_metadata_format.txt | 14 ++++++++++++++ test/extract.spec.ts | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 test/data/extract/criterion_output_with_metadata_format.txt diff --git a/test/data/extract/criterion_output_with_metadata_format.txt b/test/data/extract/criterion_output_with_metadata_format.txt new file mode 100644 index 0000000..7a39c39 --- /dev/null +++ b/test/data/extract/criterion_output_with_metadata_format.txt @@ -0,0 +1,14 @@ +WARNING: HTML report generation will become a non-default optional feature in Criterion.rs 0.4.0. +This feature is being moved to cargo-criterion (https://github.com/bheisler/cargo-criterion) and will be optional in a future version of Criterion.rs. To silence this warning, either switch to cargo-criterion or enable the 'html_reports' feature in your Cargo.toml. + +Gnuplot not found, using plotters backend +test ML-KEM/512/PK Validation// ... bench: 329 ns/iter (+/- 4) + +test ML-KEM/512/PK Validation/neon/unpacked (Execution) ... bench: 3268 ns/iter (+/- 47) + +test ML-KEM/768/PK Validation/neon/unpacked (Execution) ... bench: 12314 ns/iter (+/- 123) + + +Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 8.5s, enable flat sampling, or reduce sample count to 50. +test ML-KEM/512/PK Validation/neon/unpacked (external random) (Execution) ... bench: 1672496 ns/iter (+/- 10166) + diff --git a/test/extract.spec.ts b/test/extract.spec.ts index 3d5eedf..c8b99a3 100644 --- a/test/extract.spec.ts +++ b/test/extract.spec.ts @@ -28,6 +28,10 @@ describe('extractData()', function () { tool: 'cargo', file: 'criterion_output.txt', }, + { + tool: 'cargo', + file: 'criterion_output_with_metadata_format.txt', + }, ]; it.each(normalCases)(`extracts benchmark output from $tool - $file`, async function (test) { From 3a5b3deedb9f3ec17cfc8461d19dd719d3bde1eb Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 16:43:18 +0200 Subject: [PATCH 03/13] update snapshot to include the new test case --- test/__snapshots__/extract.spec.ts.snap | 253 ++++++++++++++++++++---- 1 file changed, 219 insertions(+), 34 deletions(-) diff --git a/test/__snapshots__/extract.spec.ts.snap b/test/__snapshots__/extract.spec.ts.snap index 0fe50c7..01016f0 100644 --- a/test/__snapshots__/extract.spec.ts.snap +++ b/test/__snapshots__/extract.spec.ts.snap @@ -3,15 +3,23 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output.txt 1`] = ` [ { - "name": "bench_fib_10", + "api": undefined, + "category": "bench_fib_10", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 24", "unit": "ns/iter", "value": 135, }, { - "name": "bench_fib_20", + "api": undefined, + "category": "bench_fib_20", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 755", "unit": "ns/iter", "value": 18149, @@ -22,36 +30,56 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output.txt 1 exports[`extractData() extracts benchmark output from cargo - cargo_output_units.txt 1`] = ` [ { - "name": "cmov", + "api": undefined, + "category": "cmov", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 14", "unit": "cycles/iter", "value": 2835, }, { - "name": "cmov2", + "api": undefined, + "category": "cmov2", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 19", "unit": "cycles/iter", "value": 2845, }, { - "name": "mov", + "api": undefined, + "category": "mov", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 17", "unit": "cycles/iter", "value": 1508, }, { - "name": "upload", + "api": undefined, + "category": "upload", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 420", "unit": "MS/s", "value": 1911, }, { - "name": "download", + "api": undefined, + "category": "download", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 69", "unit": "MS/s", "value": 9001, @@ -62,29 +90,45 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output_units exports[`extractData() extracts benchmark output from cargo - cargo_output2.txt 1`] = ` [ { - "name": "bench_engine_new", + "api": undefined, + "category": "bench_engine_new", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 70126", "unit": "ns/iter", "value": 211834, }, { - "name": "bench_engine_new_raw", + "api": undefined, + "category": "bench_engine_new_raw", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 18", "unit": "ns/iter", "value": 197, }, { - "name": "bench_engine_new_raw_core", + "api": undefined, + "category": "bench_engine_new_raw_core", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 31", "unit": "ns/iter", "value": 196, }, { - "name": "bench_engine_register_fn", + "api": undefined, + "category": "bench_engine_register_fn", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 82", "unit": "ns/iter", "value": 493, @@ -95,15 +139,23 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output2.txt exports[`extractData() extracts benchmark output from cargo - cargo_output3.txt 1`] = ` [ { - "name": "bench_fib_10", + "api": undefined, + "category": "bench_fib_10", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 2.21", "unit": "ns/iter", "value": 148.7, }, { - "name": "bench_fib_20", + "api": undefined, + "category": "bench_fib_20", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 440.25", "unit": "ns/iter", "value": 18794.12, @@ -114,29 +166,94 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output3.txt exports[`extractData() extracts benchmark output from cargo - criterion_output.txt 1`] = ` [ { - "name": "Create Realm", + "api": undefined, + "category": "Create Realm", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 4", "unit": "ns/iter", "value": 329, }, { - "name": "Symbols (Execution)", + "api": undefined, + "category": "Symbols (Execution)", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 47", "unit": "ns/iter", "value": 3268, }, { - "name": "For loop (Execution)", + "api": undefined, + "category": "For loop (Execution)", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 123", "unit": "ns/iter", "value": 12314, }, { - "name": "Fibonacci (Execution)", + "api": undefined, + "category": "Fibonacci (Execution)", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, + "range": "± 10166", + "unit": "ns/iter", + "value": 1672496, + }, +] +`; + +exports[`extractData() extracts benchmark output from cargo - criterion_output_with_metadata_format.txt 1`] = ` +[ + { + "api": "", + "category": "ML-KEM", + "keySize": 512, + "name": "PK Validation", + "os": "ubuntu-latest", + "platform": "", + "range": "± 4", + "unit": "ns/iter", + "value": 329, + }, + { + "api": "unpacked (Execution)", + "category": "ML-KEM", + "keySize": 512, + "name": "PK Validation", + "os": "ubuntu-latest", + "platform": "neon", + "range": "± 47", + "unit": "ns/iter", + "value": 3268, + }, + { + "api": "unpacked (Execution)", + "category": "ML-KEM", + "keySize": 768, + "name": "PK Validation", + "os": "ubuntu-latest", + "platform": "neon", + "range": "± 123", + "unit": "ns/iter", + "value": 12314, + }, + { + "api": "unpacked (external random) (Execution)", + "category": "ML-KEM", + "keySize": 512, + "name": "PK Validation", + "os": "ubuntu-latest", + "platform": "neon", "range": "± 10166", "unit": "ns/iter", "value": 1672496, @@ -147,15 +264,23 @@ exports[`extractData() extracts benchmark output from cargo - criterion_output.t exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_output.txt 1`] = ` [ { - "name": "bench_fib_10", + "api": undefined, + "category": "bench_fib_10", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 24", "unit": "ns/iter", "value": 135, }, { - "name": "bench_fib_20", + "api": undefined, + "category": "bench_fib_20", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 755", "unit": "ns/iter", "value": 18149, @@ -166,36 +291,56 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_output_units.txt 1`] = ` [ { - "name": "cmov", + "api": undefined, + "category": "cmov", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 14", "unit": "cycles/iter", "value": 2835, }, { - "name": "cmov2", + "api": undefined, + "category": "cmov2", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 19", "unit": "cycles/iter", "value": 2845, }, { - "name": "mov", + "api": undefined, + "category": "mov", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 17", "unit": "cycles/iter", "value": 1508, }, { - "name": "upload", + "api": undefined, + "category": "upload", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 420", "unit": "MS/s", "value": 1911, }, { - "name": "download", + "api": undefined, + "category": "download", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 69", "unit": "MS/s", "value": 9001, @@ -206,29 +351,45 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_output2.txt 1`] = ` [ { - "name": "bench_engine_new", + "api": undefined, + "category": "bench_engine_new", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 70126", "unit": "ns/iter", "value": 211834, }, { - "name": "bench_engine_new_raw", + "api": undefined, + "category": "bench_engine_new_raw", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 18", "unit": "ns/iter", "value": 197, }, { - "name": "bench_engine_new_raw_core", + "api": undefined, + "category": "bench_engine_new_raw_core", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 31", "unit": "ns/iter", "value": 196, }, { - "name": "bench_engine_register_fn", + "api": undefined, + "category": "bench_engine_register_fn", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 82", "unit": "ns/iter", "value": 493, @@ -239,15 +400,23 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_output3.txt 1`] = ` [ { - "name": "bench_fib_10", + "api": undefined, + "category": "bench_fib_10", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 2.21", "unit": "ns/iter", "value": 148.7, }, { - "name": "bench_fib_20", + "api": undefined, + "category": "bench_fib_20", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 440.25", "unit": "ns/iter", "value": 18794.12, @@ -258,29 +427,45 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp exports[`localWriteBenchmark() extracts benchmark output from cargo - criterion_output.txt 1`] = ` [ { - "name": "Create Realm", + "api": undefined, + "category": "Create Realm", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 4", "unit": "ns/iter", "value": 329, }, { - "name": "Symbols (Execution)", + "api": undefined, + "category": "Symbols (Execution)", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 47", "unit": "ns/iter", "value": 3268, }, { - "name": "For loop (Execution)", + "api": undefined, + "category": "For loop (Execution)", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 123", "unit": "ns/iter", "value": 12314, }, { - "name": "Fibonacci (Execution)", + "api": undefined, + "category": "Fibonacci (Execution)", + "keySize": NaN, + "name": undefined, "os": "ubuntu-latest", + "platform": undefined, "range": "± 10166", "unit": "ns/iter", "value": 1672496, From 9edabb86de4898d9cdc2feba5c26c2057521244b Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 16:43:46 +0200 Subject: [PATCH 04/13] parse new fields --- src/extract.ts | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/src/extract.ts b/src/extract.ts index ba6158d..54d4b0e 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -3,12 +3,45 @@ import { promises as fs } from 'fs'; import { Config } from './config'; export interface BenchmarkResult { - name: string; value: number; range?: string; unit: string; extra?: string; os: string; + + // from NameMetadata + category: string; + keySize: number; + name: string; + platform: string; + api: string; +} + +interface NameMetadata { + category: string; + keySize: number; + name: string; + platform: string; + api: string; +} +function extractMetadataFromName(name_string: string): NameMetadata { + // split by separator + const values = name_string.split('/'); + + // extract by position + const category = values[0]; + const keySize = parseInt(values[1]); + const name = values[2]; + const platform = values[3]; + const api = values[4]; + + return { + category, + keySize, + name, + platform, + api, + }; } function extractCargoResult(config: Config, output: string): BenchmarkResult[] { @@ -23,17 +56,24 @@ function extractCargoResult(config: Config, output: string): BenchmarkResult[] { continue; } - const name = m[1].trim(); + const name_string = m[1].trim(); const value = parseFloat(m[2].replace(reComma, '')); const unit = m[3].trim(); const range = m[4].replace(reComma, ''); + // TODO: error handling + const { category, keySize, name, platform, api } = extractMetadataFromName(name_string); + ret.push({ - name, value, range: `± ${range}`, unit: unit, os: config.os, + category, + keySize, + name, + platform, + api, }); } From cd55a69257f44ad883d5b77aa047880801fa655a Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 17:07:09 +0200 Subject: [PATCH 05/13] remove extra `(Execution)` at end of names --- .../extract/criterion_output_with_metadata_format.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/data/extract/criterion_output_with_metadata_format.txt b/test/data/extract/criterion_output_with_metadata_format.txt index 7a39c39..dc900ca 100644 --- a/test/data/extract/criterion_output_with_metadata_format.txt +++ b/test/data/extract/criterion_output_with_metadata_format.txt @@ -2,13 +2,13 @@ WARNING: HTML report generation will become a non-default optional feature in Cr This feature is being moved to cargo-criterion (https://github.com/bheisler/cargo-criterion) and will be optional in a future version of Criterion.rs. To silence this warning, either switch to cargo-criterion or enable the 'html_reports' feature in your Cargo.toml. Gnuplot not found, using plotters backend -test ML-KEM/512/PK Validation// ... bench: 329 ns/iter (+/- 4) +test ML-KEM/1024/PK Validation// ... bench: 329 ns/iter (+/- 4) -test ML-KEM/512/PK Validation/neon/unpacked (Execution) ... bench: 3268 ns/iter (+/- 47) +test ML-KEM/512/PK Validation/neon/unpacked ... bench: 3268 ns/iter (+/- 47) -test ML-KEM/768/PK Validation/neon/unpacked (Execution) ... bench: 12314 ns/iter (+/- 123) +test ML-KEM/768/PK Validation/neon/unpacked ... bench: 12314 ns/iter (+/- 123) Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 8.5s, enable flat sampling, or reduce sample count to 50. -test ML-KEM/512/PK Validation/neon/unpacked (external random) (Execution) ... bench: 1672496 ns/iter (+/- 10166) +test ML-KEM/512/PK Validation/neon/unpacked (external random) ... bench: 1672496 ns/iter (+/- 10166) From 4af9552f3248b1521077f954fb93464340ee321f Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 17:07:35 +0200 Subject: [PATCH 06/13] parse undefined values correctly --- src/extract.ts | 42 +++-- test/__snapshots__/extract.spec.ts.snap | 216 ++++++++++++------------ 2 files changed, 137 insertions(+), 121 deletions(-) diff --git a/src/extract.ts b/src/extract.ts index 54d4b0e..71d2cf5 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -10,30 +10,46 @@ export interface BenchmarkResult { os: string; // from NameMetadata - category: string; - keySize: number; + category: string | undefined; + keySize: number | undefined; name: string; - platform: string; - api: string; + platform: string | undefined; + api: string | undefined; } interface NameMetadata { - category: string; - keySize: number; + category: string | undefined; + keySize: number | undefined; name: string; - platform: string; - api: string; + platform: string | undefined; + api: string | undefined; } function extractMetadataFromName(name_string: string): NameMetadata { // split by separator const values = name_string.split('/'); + // if only one arg provided, just returnname + if (values.length == 1) { + const name = name_string; + return { name, keySize: undefined, category: undefined, platform: undefined, api: undefined }; + } + // extract by position - const category = values[0]; - const keySize = parseInt(values[1]); - const name = values[2]; - const platform = values[3]; - const api = values[4]; + const category = values[0] === '' ? undefined : values[0]; + + // If keySize not a number, use `undefined` + const keySizeParsed = parseInt(values[1]); + + const keySize = isNaN(keySizeParsed) ? undefined : keySizeParsed; + + // if name is not defined, keep entire name_string as name + let name = values[2]; + if (name === undefined || name === '') { + name = name_string; + } + + const platform = values[3] === '' ? undefined : values[3]; + const api = values[4] === '' ? undefined : values[4]; return { category, diff --git a/test/__snapshots__/extract.spec.ts.snap b/test/__snapshots__/extract.spec.ts.snap index 01016f0..5707f18 100644 --- a/test/__snapshots__/extract.spec.ts.snap +++ b/test/__snapshots__/extract.spec.ts.snap @@ -4,9 +4,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output.txt 1 [ { "api": undefined, - "category": "bench_fib_10", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_fib_10", "os": "ubuntu-latest", "platform": undefined, "range": "± 24", @@ -15,9 +15,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output.txt 1 }, { "api": undefined, - "category": "bench_fib_20", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_fib_20", "os": "ubuntu-latest", "platform": undefined, "range": "± 755", @@ -31,9 +31,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output_units [ { "api": undefined, - "category": "cmov", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "cmov", "os": "ubuntu-latest", "platform": undefined, "range": "± 14", @@ -42,9 +42,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output_units }, { "api": undefined, - "category": "cmov2", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "cmov2", "os": "ubuntu-latest", "platform": undefined, "range": "± 19", @@ -53,9 +53,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output_units }, { "api": undefined, - "category": "mov", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "mov", "os": "ubuntu-latest", "platform": undefined, "range": "± 17", @@ -64,9 +64,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output_units }, { "api": undefined, - "category": "upload", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "upload", "os": "ubuntu-latest", "platform": undefined, "range": "± 420", @@ -75,9 +75,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output_units }, { "api": undefined, - "category": "download", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "download", "os": "ubuntu-latest", "platform": undefined, "range": "± 69", @@ -91,9 +91,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output2.txt [ { "api": undefined, - "category": "bench_engine_new", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_engine_new", "os": "ubuntu-latest", "platform": undefined, "range": "± 70126", @@ -102,9 +102,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output2.txt }, { "api": undefined, - "category": "bench_engine_new_raw", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_engine_new_raw", "os": "ubuntu-latest", "platform": undefined, "range": "± 18", @@ -113,9 +113,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output2.txt }, { "api": undefined, - "category": "bench_engine_new_raw_core", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_engine_new_raw_core", "os": "ubuntu-latest", "platform": undefined, "range": "± 31", @@ -124,9 +124,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output2.txt }, { "api": undefined, - "category": "bench_engine_register_fn", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_engine_register_fn", "os": "ubuntu-latest", "platform": undefined, "range": "± 82", @@ -140,9 +140,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output3.txt [ { "api": undefined, - "category": "bench_fib_10", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_fib_10", "os": "ubuntu-latest", "platform": undefined, "range": "± 2.21", @@ -151,9 +151,9 @@ exports[`extractData() extracts benchmark output from cargo - cargo_output3.txt }, { "api": undefined, - "category": "bench_fib_20", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_fib_20", "os": "ubuntu-latest", "platform": undefined, "range": "± 440.25", @@ -167,9 +167,9 @@ exports[`extractData() extracts benchmark output from cargo - criterion_output.t [ { "api": undefined, - "category": "Create Realm", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "Create Realm", "os": "ubuntu-latest", "platform": undefined, "range": "± 4", @@ -178,9 +178,9 @@ exports[`extractData() extracts benchmark output from cargo - criterion_output.t }, { "api": undefined, - "category": "Symbols (Execution)", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "Symbols (Execution)", "os": "ubuntu-latest", "platform": undefined, "range": "± 47", @@ -189,9 +189,9 @@ exports[`extractData() extracts benchmark output from cargo - criterion_output.t }, { "api": undefined, - "category": "For loop (Execution)", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "For loop (Execution)", "os": "ubuntu-latest", "platform": undefined, "range": "± 123", @@ -200,9 +200,9 @@ exports[`extractData() extracts benchmark output from cargo - criterion_output.t }, { "api": undefined, - "category": "Fibonacci (Execution)", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "Fibonacci (Execution)", "os": "ubuntu-latest", "platform": undefined, "range": "± 10166", @@ -215,18 +215,18 @@ exports[`extractData() extracts benchmark output from cargo - criterion_output.t exports[`extractData() extracts benchmark output from cargo - criterion_output_with_metadata_format.txt 1`] = ` [ { - "api": "", + "api": undefined, "category": "ML-KEM", - "keySize": 512, + "keySize": 1024, "name": "PK Validation", "os": "ubuntu-latest", - "platform": "", + "platform": undefined, "range": "± 4", "unit": "ns/iter", "value": 329, }, { - "api": "unpacked (Execution)", + "api": "unpacked", "category": "ML-KEM", "keySize": 512, "name": "PK Validation", @@ -237,7 +237,7 @@ exports[`extractData() extracts benchmark output from cargo - criterion_output_w "value": 3268, }, { - "api": "unpacked (Execution)", + "api": "unpacked", "category": "ML-KEM", "keySize": 768, "name": "PK Validation", @@ -248,7 +248,7 @@ exports[`extractData() extracts benchmark output from cargo - criterion_output_w "value": 12314, }, { - "api": "unpacked (external random) (Execution)", + "api": "unpacked (external random)", "category": "ML-KEM", "keySize": 512, "name": "PK Validation", @@ -265,9 +265,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp [ { "api": undefined, - "category": "bench_fib_10", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_fib_10", "os": "ubuntu-latest", "platform": undefined, "range": "± 24", @@ -276,9 +276,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp }, { "api": undefined, - "category": "bench_fib_20", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_fib_20", "os": "ubuntu-latest", "platform": undefined, "range": "± 755", @@ -292,9 +292,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp [ { "api": undefined, - "category": "cmov", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "cmov", "os": "ubuntu-latest", "platform": undefined, "range": "± 14", @@ -303,9 +303,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp }, { "api": undefined, - "category": "cmov2", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "cmov2", "os": "ubuntu-latest", "platform": undefined, "range": "± 19", @@ -314,9 +314,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp }, { "api": undefined, - "category": "mov", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "mov", "os": "ubuntu-latest", "platform": undefined, "range": "± 17", @@ -325,9 +325,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp }, { "api": undefined, - "category": "upload", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "upload", "os": "ubuntu-latest", "platform": undefined, "range": "± 420", @@ -336,9 +336,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp }, { "api": undefined, - "category": "download", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "download", "os": "ubuntu-latest", "platform": undefined, "range": "± 69", @@ -352,9 +352,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp [ { "api": undefined, - "category": "bench_engine_new", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_engine_new", "os": "ubuntu-latest", "platform": undefined, "range": "± 70126", @@ -363,9 +363,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp }, { "api": undefined, - "category": "bench_engine_new_raw", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_engine_new_raw", "os": "ubuntu-latest", "platform": undefined, "range": "± 18", @@ -374,9 +374,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp }, { "api": undefined, - "category": "bench_engine_new_raw_core", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_engine_new_raw_core", "os": "ubuntu-latest", "platform": undefined, "range": "± 31", @@ -385,9 +385,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp }, { "api": undefined, - "category": "bench_engine_register_fn", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_engine_register_fn", "os": "ubuntu-latest", "platform": undefined, "range": "± 82", @@ -401,9 +401,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp [ { "api": undefined, - "category": "bench_fib_10", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_fib_10", "os": "ubuntu-latest", "platform": undefined, "range": "± 2.21", @@ -412,9 +412,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - cargo_outp }, { "api": undefined, - "category": "bench_fib_20", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "bench_fib_20", "os": "ubuntu-latest", "platform": undefined, "range": "± 440.25", @@ -428,9 +428,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - criterion_ [ { "api": undefined, - "category": "Create Realm", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "Create Realm", "os": "ubuntu-latest", "platform": undefined, "range": "± 4", @@ -439,9 +439,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - criterion_ }, { "api": undefined, - "category": "Symbols (Execution)", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "Symbols (Execution)", "os": "ubuntu-latest", "platform": undefined, "range": "± 47", @@ -450,9 +450,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - criterion_ }, { "api": undefined, - "category": "For loop (Execution)", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "For loop (Execution)", "os": "ubuntu-latest", "platform": undefined, "range": "± 123", @@ -461,9 +461,9 @@ exports[`localWriteBenchmark() extracts benchmark output from cargo - criterion_ }, { "api": undefined, - "category": "Fibonacci (Execution)", - "keySize": NaN, - "name": undefined, + "category": undefined, + "keySize": undefined, + "name": "Fibonacci (Execution)", "os": "ubuntu-latest", "platform": undefined, "range": "± 10166", From 7cc8b1be8a16e65346d28aaca7ca02689ad069a7 Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 17:10:59 +0200 Subject: [PATCH 07/13] `platform`->`os` in action input, and change os to `'ubuntu-latest'` --- .github/workflows/build-and-test.yml | 8 ++++---- .github/workflows/minimal.yml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 7887156..2b557c5 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -19,24 +19,24 @@ jobs: - uses: ./ # local action in repo with: tool: 'cargo' - platform: 'default' + os: 'ubuntu-latest' output-file-path: ./test/data/extract/cargo_output.txt data-out-path: output.txt - uses: ./ # local action in repo with: tool: 'cargo' - platform: 'default' + os: 'ubuntu-latest' output-file-path: ./test/data/extract/cargo_output2.txt data-out-path: output.txt - uses: ./ # local action in repo with: tool: 'cargo' - platform: 'default' + os: 'ubuntu-latest' output-file-path: ./test/data/extract/cargo_output3.txt data-out-path: output.txt - uses: ./ # local action in repo with: tool: 'cargo' - platform: 'default' + os: 'ubuntu-latest' output-file-path: ./test/data/extract/criterion_output.txt data-out-path: output.txt diff --git a/.github/workflows/minimal.yml b/.github/workflows/minimal.yml index 5fe3060..0099b65 100644 --- a/.github/workflows/minimal.yml +++ b/.github/workflows/minimal.yml @@ -16,6 +16,6 @@ jobs: - uses: ./ # local action in repo with: tool: 'cargo' - platform: 'default' + os: 'ubuntu-latest' output-file-path: ./test/data/extract/cargo_output.txt data-out-path: output.txt From f646e5205134e50f83daa5d450345d84c4343813 Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 17:12:21 +0200 Subject: [PATCH 08/13] documentation --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dfcc1df..63d209d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Currently supported sources: ## Fields - `name` (required): name of the benchmark - `tool` (required): tool used to get benchmark output. One of `["cargo"]` -- `platform` (required): a string describing the platform +- `os` (required): a string describing the os - `output-file-path` (required): a path to a file containing the output of the benchmark tool - `data-out-path` (required): the path where the output of the action should be written @@ -21,7 +21,7 @@ The output will be written to `data-out-path` in a standardized JSON format: { "name": "My Custom Smaller Is Better Benchmark - Memory Used", "unit": "Megabytes", - "platform": "ubuntu-latest", + "os": "ubuntu-latest", "value": 100, "range": "3", } From fb7da3bdd2c2b39a43d39cd7c9214a95a416b803 Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 17:13:33 +0200 Subject: [PATCH 09/13] fix lints --- src/extract.ts | 2 +- test/extract.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/extract.ts b/src/extract.ts index 71d2cf5..0003891 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -29,7 +29,7 @@ function extractMetadataFromName(name_string: string): NameMetadata { const values = name_string.split('/'); // if only one arg provided, just returnname - if (values.length == 1) { + if (values.length === 1) { const name = name_string; return { name, keySize: undefined, category: undefined, platform: undefined, api: undefined }; } diff --git a/test/extract.spec.ts b/test/extract.spec.ts index c8b99a3..7798581 100644 --- a/test/extract.spec.ts +++ b/test/extract.spec.ts @@ -123,7 +123,7 @@ describe('localWriteBenchmark()', function () { expect(benches).toMatchSnapshot(); // write out - localWriteBenchmark(benches, config); + await localWriteBenchmark(benches, config); jest.useRealTimers(); }); From 95154d6f99f31802d6414fd496eaf7d5f0713be2 Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 17:28:21 +0200 Subject: [PATCH 10/13] rename `Platform` to `Os` in `config.ts` --- src/config.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config.ts b/src/config.ts index ad6f037..474888f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -71,11 +71,11 @@ function validateName(name: string) { } throw new Error('Name must not be empty'); } -function validatePlatform(os: string) { +function validateOs(os: string) { if (os) { return; } - throw new Error('Platform must not be empty'); + throw new Error('Os must not be empty'); } export async function configFromJobInput(): Promise { @@ -86,7 +86,7 @@ export async function configFromJobInput(): Promise { const os: string = core.getInput('os'); validateName(name); - validatePlatform(os); + validateOs(os); validateToolType(tool); outputFilePath = await validateOutputFilePath(outputFilePath); dataOutPath = await validateDataOutPath(dataOutPath); From b912d593537200b90d47e4e3e09962cbfe3f3bea Mon Sep 17 00:00:00 2001 From: wysiwys Date: Wed, 2 Apr 2025 17:31:12 +0200 Subject: [PATCH 11/13] fix typo in docs --- src/extract.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extract.ts b/src/extract.ts index 0003891..d163699 100644 --- a/src/extract.ts +++ b/src/extract.ts @@ -28,7 +28,7 @@ function extractMetadataFromName(name_string: string): NameMetadata { // split by separator const values = name_string.split('/'); - // if only one arg provided, just returnname + // if only one arg provided, just return name if (values.length === 1) { const name = name_string; return { name, keySize: undefined, category: undefined, platform: undefined, api: undefined }; From e8e6a75cfa51347ba0667e8f183bfdaa7a12aa79 Mon Sep 17 00:00:00 2001 From: wysiwys Date: Thu, 3 Apr 2025 10:24:20 +0200 Subject: [PATCH 12/13] add info about metadata format to README --- README.md | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 63d209d..4467434 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,31 @@ Currently supported sources: - `criterion` ## Fields -- `name` (required): name of the benchmark +- `name` (required): name of the benchmark. This can optionally be specified with a given metadata format (see below) - `tool` (required): tool used to get benchmark output. One of `["cargo"]` - `os` (required): a string describing the os - `output-file-path` (required): a path to a file containing the output of the benchmark tool - `data-out-path` (required): the path where the output of the action should be written +## Metadata format + +The `name` field can be provided as a `/`-separated string with the format `category/key size/name/platform/api`. The key size should be an integer. Some fields in this string can be left blank. Any unspecified or invalid fields will be parsed to `undefined`. + ## Output data format The output will be written to `data-out-path` in a standardized JSON format: ```json [ - { - "name": "My Custom Smaller Is Better Benchmark - Memory Used", - "unit": "Megabytes", - "os": "ubuntu-latest", - "value": 100, - "range": "3", - } + { + "api": "unpacked", + "category": "ML-KEM", + "keySize": 768, + "name": "PK Validation", + "os": "ubuntu-latest", + "platform": "neon", + "range": "± 123", + "unit": "ns/iter", + "value": 12314, + }, ] ``` From b82396f2afca8369648592300224d814c61bf6e2 Mon Sep 17 00:00:00 2001 From: wysiwys Date: Thu, 3 Apr 2025 10:30:23 +0200 Subject: [PATCH 13/13] make sure the two `name` fields are distinct --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4467434..d91a0d7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Currently supported sources: - `criterion` ## Fields -- `name` (required): name of the benchmark. This can optionally be specified with a given metadata format (see below) +- `name` (required): name of the benchmark - `tool` (required): tool used to get benchmark output. One of `["cargo"]` - `os` (required): a string describing the os - `output-file-path` (required): a path to a file containing the output of the benchmark tool @@ -15,7 +15,7 @@ Currently supported sources: ## Metadata format -The `name` field can be provided as a `/`-separated string with the format `category/key size/name/platform/api`. The key size should be an integer. Some fields in this string can be left blank. Any unspecified or invalid fields will be parsed to `undefined`. +The benchmark name in the `cargo` benchmarks can be provided as a `/`-separated string with the format `category/key size/name/platform/api`. The key size should be an integer. Some fields in this string can be left blank. Any unspecified or invalid fields will be parsed to `undefined`. ## Output data format