Cómo Seguir el Tamaño de Archivo con Bencher
Bencher supports the most popular benchmarking harnesses out-of-the-box.
Sometimes though, you want to measure the size of your deliverables themselves,
such as the binary size of an executable.
Lucky for you, Bencher also supports tracking file size.
The easiest way to track file size is to use the
bencher run
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, bencher run
outputs the results as Bencher Metric Format (BMF) JSON.
It is therefore good practice to explicitly use the json
adapter.
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
bencher run
and the json
adapter.
This would work both with a benchmark command and without one.
With a benchmark command:
Without a benchmark command:
In either case, the generated BMF JSON would look like this,
if my_binary
had a size of 42
bytes:
In this example, the key my_binary
is the binary file name.
It is used as the name of the Benchmark.
The my_binary
object contains the file-size
key.
file-size
is the slug for the built-in File Size 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
with the file size value
in bytes, 42.0
.
The File Size will always be a whole byte increment.
That is, it will never have a decimal like 42.5
.
However, BMF JSON needs to support a wide range of possible values,
so it uses floats instead of integers.
Seguimiento del Tiempo de Compilación
Puede que desees realizar un seguimiento del tiempo de compilación de tus entregables, además de seguir su tamaño de archivo.
bencher run
admite el seguimiento tanto de los tamaños de archivo como de los tiempos de compilación.
Podrías realizar un seguimiento tanto del tamaño del binario como del tiempo de compilación para my_binary
con este comando:
Si tu script de compilación tardó 87.0
segundos en completarse,
el JSON BMF generado se vería así:
🐰 ¡Felicidades! ¡Has aprendido cómo seguir el tamaño de tu archivo! 🎉