Bencherでカスタムベンチマークを追跡する方法
Bencher supports the most popular benchmarking harnesses out-of-the-box, and we are always open to suggestions for new adapters. However there can be situations where an off-the-shelf benchmarking harness doesn’t fit your needs, necessitating the creation of a custom benchmarking harness. Lucky for you, Bencher also supports using a custom benchmarking harness. The easiest way to integrate your custom benchmark harness with Bencher is to output Bencher Metric Format (BMF) JSON.
This is an example of BMF JSON:
{ "benchmark_name": { "latency": { "value": 88.0, "lower_value": 87.42, "upper_value": 88.88 } }}In this example, the key benchmark_name would be the name of a Benchmark.
Benchmark names can be any non-empty string up to 1024 characters.
The benchmark_name object can contain multiple Measure names, slugs, or UUIDs as keys.
If the value specified is a name or slug and the Measure does not already exist, it will be created for you.
However, if the value specified is a UUID then the Measure must already exist.
In this example, latency is the slug for the built-in Latency Measure.
Each Project by default has a Latency (ie latency) and Throughput (ie throughput) Measure,
which are measured in nanosecond (ns) and operations / second (ops/s) respectively.
The Measure object contains a Metric with up to three values:
value, lower_value, and upper_value.
The lower_value and upper_value values are optional.
In this example, the latency Measure object contains the following values:
- A
valueof88.0 - A
lower_valueof87.42 - An
upper_valueof88.88
You can use the bencher mock CLI subcommand to generate mock BMF data.
We will use it as a placeholder for your own custom benchmark runner.
Using bencher run
and the json adapter
we can track our benchmarks with the following command:
bencher run --adapter json "bencher mock"If your results were instead stored in a file named results.json,
then you could use the --file option to specify the file path.
This works both with a benchmark command and without one.
With a benchmark command:
bencher run --file results.json --adapter json "bencher mock > results.json"Without a benchmark command:
bencher mock > results.json && bencher run --file results.json --adapter json複数のメジャー
ベンチャー メトリック フォーマット (BMF) JSON では、ベンチマーク オブジェクトに複数の メジャー 名、スラグ、または UUID をキーとして含めることができます。指定された値が名前またはスラグであり、メジャーが既に存在しない場合は、自動的に作成されます。ただし、指定された値が UUID の場合は、メジャーは既に存在している必要があります。各メジャーオブジェクトには、最大 3 つの値 (value、lower_value、および upper_value) を持つ メトリック を含める必要があります。lower_value と upper_value の値はオプションです。
以下は、複数のメジャーを持つ BMF JSON の例です:
{ "benchmark_name": { "latency": { "value": 88.0, "lower_value": 87.42, "upper_value": 88.88 }, "throughput" { "value": 5.55, "lower_value": 3.14, "upper_value": 6.30 } }}この例では、latency メジャーオブジェクトには次の値が含まれています:
valueは88.0lower_valueは87.42upper_valueは88.88
そして、throughput メジャーオブジェクトには次の値が含まれています:
valueは5.55lower_valueは3.14upper_valueは6.30
あなたは ベンチャー mock CLI サブコマンド と —measure オプション を使用して、複数のメジャーを持つモック BMF データを生成することができます。これは、独自のカスタムベンチマークランナーのプレースホルダーとして使用します。bencher run と json アダプター を使用して、次のコマンドで複数のメジャーを持つベンチマークを追跡できます:
bencher run --adapter json "bencher mock --measure latency --measure throughput"🐰 おめでとうございます!カスタムベンチマークの追跡方法を学びました!🎉