sharkdp/hyperfine

${HYPERFINE_ITERATION} is not visible in prepare or conclude commands

Open

#781 创建于 2024年12月3日

在 GitHub 查看
 (4 评论) (0 反应) (0 负责人)Rust (28,110 star) (479 fork)batch import
feature-requestgood first issue

描述

I thought I could use the ${HYPERFINE_ITERATION} env variable that is exposed (mentioned as a solution in https://github.com/sharkdp/hyperfine/issues/778) ; however this is only accessible in the main command of the iteration, not the prepare or conclude steps for each iteration.

So for example if I want to prepare , test and cleanup a series of files, I would do something like this (with echo for illustrative purposes) :

 ~/hyperfine --runs 5 --prepare 'echo touch file${HYPERFINE_ITERATION}.dat' \
                  'echo testing file${HYPERFINE_ITERATION}.dat' \
                  --conclude 'echo rm file${HYPERFINE_ITERATION}.dat' --show-output

However this does not work because the env var is not exposed in all the steps:

Benchmark 1: echo testing file${HYPERFINE_ITERATION}.dat
touch file.dat
testing file0.dat
rm file.dat
touch file.dat
testing file1.dat
rm file.dat
touch file.dat
testing file2.dat
rm file.dat
touch file.dat
testing file3.dat
rm file.dat
touch file.dat
testing file4.dat
rm file.dat
  Time (mean ± σ):      90.7 µs ± 202.8 µs    [User: 116.6 µs, System: 252.7 µs]
  Range (min … max):     0.0 µs … 453.5 µs    5 runs

so it's not possible to prepare and clean up each file.

贡献者指南

${HYPERFINE_ITERATION} is not visible in prepare or conclude commands · sharkdp/hyperfine#781 | Good First Issue