Skip to content

Commit

Permalink
bench : fix timings by running a pre-heat
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Sep 13, 2023
1 parent d863f72 commit f408c64
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions examples/bench/bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ int whisper_bench_encoder(const whisper_params & params) {
return 3;
}

// heat up
if (int ret = whisper_encode(ctx, 0, params.n_threads) != 0) {
fprintf(stderr, "error: failed to encode model: %d\n", ret);
return 4;
}

whisper_reset_timings(ctx);

// actual run
if (int ret = whisper_encode(ctx, 0, params.n_threads) != 0) {
fprintf(stderr, "error: failed to encode model: %d\n", ret);
return 4;
Expand Down
3 changes: 0 additions & 3 deletions extra/bench-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ printf "| CPU | OS | Config | Model | Th | Load | Enc. | Commit |\n"
printf "| --- | -- | ------ | ----- | -- | ---- | ---- | ------ |\n"

for model in "${models[@]}"; do
# run once to heat-up the cache
./bench -m ./models/ggml-$model.bin -t $n_threads 2>/dev/null 1>/dev/null

# actual run
# store stderr output in a variable in order to parse it later
output=$(./bench -m ./models/ggml-$model.bin -t $n_threads 2>&1)
Expand Down
3 changes: 3 additions & 0 deletions whisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3588,6 +3588,9 @@ void whisper_reset_timings(struct whisper_context * ctx) {
ctx->state->t_sample_us = 0;
ctx->state->t_encode_us = 0;
ctx->state->t_decode_us = 0;
ctx->state->n_sample = 0;
ctx->state->n_encode = 0;
ctx->state->n_decode = 0;
}
}

Expand Down

0 comments on commit f408c64

Please sign in to comment.