Skip to content

Commit

Permalink
file_size
Browse files Browse the repository at this point in the history
  • Loading branch information
epompeii committed May 13, 2024
1 parent 414ec68 commit c6aeda9
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 56 deletions.
11 changes: 0 additions & 11 deletions services/console/src/chunks/explanation/adapters/bmf-example.mdx

This file was deleted.

19 changes: 0 additions & 19 deletions services/console/src/chunks/explanation/adapters/bmf-schema.mdx

This file was deleted.

19 changes: 7 additions & 12 deletions services/console/src/chunks/explanation/adapters/en/file-size.mdx
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
import FileSizeCmdExample from "../file-size-cmd-example.mdx";
import FileSizeNoCmdExample from "../file-size-no-cmd-example.mdx";

### ⚖️ File Size

The <code><a href="/docs/explanation/bencher-run/">bencher run</a></code> CLI subcommand
can be used to track the file size (ie binary size) of your deliverables with the `--file-size` option.
The `--file-size` option expects a file path to the file who's size will be measured.
Under the hood, <code><a href="/docs/explanation/bencher-run/">bencher run</a></code>
outputs the results as [Bencher Metric Format (BMF) JSON][json].
It is therefore good practice to explicitly use the `json` adapter.

With a command:
<FileSizeCmdExample />

Without a command:
<FileSizeNoCmdExample />
outputs the results as[Bencher Metric Format (BMF) JSON][bmf].
It is therefore good practice to explicitly use [the `json` adapter][json].
For more details see [how to track file size][file size].

The `file-size` Measure (ie `bytes (B)`) is gathered.
Only the file size value (ie `value`) is available.
Neither `lower_value` nor `upper_value` are collected.
The `file-size` Measure is not created by default for all Projects.
However, when you use the `--file-size` option, this Measures will be automatically created for your Project.

[json]: #-json
[json]: #-json

[bmf]: /docs/reference/bencher-metric-format/
[file size]: /docs/how-to/file-size/
3 changes: 0 additions & 3 deletions services/console/src/chunks/explanation/adapters/en/json.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import FileCmdExample from "../file-cmd-example.mdx";
import FileNoCmdExample from "../file-no-cmd-example.mdx";

## \{...\} JSON

The JSON Adapter (`json`) expects [Bencher Metric Format (BMF) JSON][bmf].
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ This is an example of BMF JSON:

In this example, the key `benchmark_name` would be the name of a [Benchmark][benchmark].
Benchmark names can be any non-empty string up to 1024 characters.
The `benchmark_name` object can contain [Measure][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.
The `benchmark_name` object can contain multiple [Measure][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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ 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][bencher run] and without one.

With a command:
With a benchmark command:
<FileCmdExample />

Without a command:
Without a benchmark command:
<FileNoCmdExample />

[bencher run]: /docs/explanation/bencher-run/#benchmark-command
38 changes: 38 additions & 0 deletions services/console/src/chunks/how_to/file-size/en/example.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import CmdExample from "../cmd-example.mdx";
import NoCmdExample from "../no-cmd-example.mdx";
import JsonExample from "../json-example.mdx";

If you had a script located at `./my_build_script.sh` that built your binary
at the path `./path/to/my_binary`,
then you could track the size of this binary file with
<code><a href="/docs/explanation/bencher-run/">bencher run</a></code>
and [the `json` adapter][json adapter].
This would work both with [a benchmark command][bencher run] and without one.

With a benchmark command:
<CmdExample />

Without a benchmark command:
<NoCmdExample />

In either case, the generated BMF JSON would look like this,
if `my_binary` had a size of `42` bytes:

<JsonExample />

In this example, the key `my_binary` is the binary file name.
It is used as the name of the [Benchmark][benchmark].
The `my_binary` object contains the `file-size` key.
`file-size` is the slug for the built-in File Size [Measure][measure].
The File Size Measure is not created by default for all Projects.
However, when you use the File Size Measure,
it will be automatically created for your Project.
The File Size Measure object contains a [Metric][metric]
with the file size `value` in bytes, `42.0`.

[json adapter]: /docs/explanation/adapters/#-json
[bencher run]: /docs/explanation/bencher-run/#benchmark-command

[benchmark]: /docs/explanation/benchmarking/#benchmarks
[measure]: /docs/explanation/benchmarking/#measures
[metric]: /docs/explanation/benchmarking/#metrics
15 changes: 15 additions & 0 deletions services/console/src/chunks/how_to/file-size/en/intro.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Bencher supports [the most popular benchmarking harnesses][adapters] out-of-the-box.
Sometimes though, you want to measure the size of your deliverables themselves,
such as the binary size of your executable.
Lucky for you, Bencher also supports tracking file size.
The easiest way to track file size is to use the
<code><a href="/docs/explanation/bencher-run/">bencher run</a></code> CLI subcommand
with the `--file-size` option.
The `--file-size` option expects a file path to the file who's size will be measured.
Under the hood, <code><a href="/docs/explanation/bencher-run/">bencher run</a></code>
outputs the results as [Bencher Metric Format (BMF) JSON][bmf].
It is therefore good practice to explicitly use [the `json` adapter][json adapter].

[adapters]: /docs/explanation/adapters/
[bmf]: /docs/reference/bencher-metric-format/
[json adapter]: /docs/explanation/adapters/#-json
9 changes: 9 additions & 0 deletions services/console/src/chunks/how_to/file-size/json-example.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
```json
{
"my_binary": {
"file-size": {
"value": 42.0,
}
}
}
```
22 changes: 22 additions & 0 deletions services/console/src/content/how_to/en/file-size.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: "Track File Size"
description: "How to track file size and binary size as a part of Continuous Benchmarking"
heading: "How to Track File Size with Bencher"
published: "2024-05-13T07:14:00Z"
modified: "2024-05-13T07:14:00Z"
sortOrder: 6
---

import Intro from "../../../chunks/how_to/file-size/en/intro.mdx";
import Example from "../../../chunks/how_to/file-size/en/example.mdx";

<Intro />
<Example />

<br/>

> 🐰 Congrats! You have learned how to track your file size! 🎉
<br/>

<h2><a href="/docs/explanation/benchmarking/">Keep Going: Benchmarking Overview ➡</a></h2>
2 changes: 1 addition & 1 deletion services/console/src/content/how_to/en/github-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Create a GitHub App to allow Bencher Self-Hosted to authenticate w
heading: "How to Create a Self-Hosted GitHub App"
published: "2023-08-12T16:07:00Z"
modified: "2024-04-01T07:00:00Z"
sortOrder: 6
sortOrder: 7
---

If you are using Bencher Cloud, then you can simply [sign up](/auth/signup) or [log in](/auth/login)
Expand Down

0 comments on commit c6aeda9

Please sign in to comment.