summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-09-04 04:18:06 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-12-31 12:20:59 +0100
commitcda8995ac8a17cc1d579f73519fd5b0f2429675a (patch)
tree351dc406ecab00db2e22938e8ce86a2f499e7431 /src/main.c
parent72218e7da04783222f04492d939268ac40585027 (diff)
benchmark: add functions to get cycle and frame count
To simplify the benchrarking process via the library API, this change introduces two new functions, which are intended to provide total cycle and frame count.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/main.c b/src/main.c
index 623926f..3596ec1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -313,32 +313,34 @@ check_options(struct gapk_state *gs)
static void
benchmark_dump(void)
{
- int i, j;
+ int i;
for (i = 0; i < _CODEC_MAX; i++) {
- struct osmo_gapk_bench_cycles *bc = osmo_gapk_bench_codec[i];
- unsigned long long total;
+ struct osmo_gapk_bench_cycles *bc;
+ unsigned long long cycles;
+ unsigned int frames;
+
+ /* Check if there are benchmark data */
+ bc = osmo_gapk_bench_codec[i];
+ if (!bc)
+ continue;
if (bc->enc_used) {
- total = 0;
- for (j = 0; j < bc->enc_used; j++)
- total += bc->enc[j];
-
- fprintf(stderr,
- "Codec %u (ENC): %llu cycles for %u frames => "
- "%llu cycles/frame\n", i, total, bc->enc_used,
- total / bc->enc_used);
+ cycles = osmo_gapk_bench_get_cycles(i, 1);
+ frames = osmo_gapk_bench_get_frames(i, 1);
+
+ fprintf(stderr, "Codec %u (ENC): %llu cycles for %u frames"
+ " => %llu cycles/frame\n", i, cycles,
+ frames, cycles / frames);
}
if (bc->dec_used) {
- total = 0;
- for (j = 0; j < bc->dec_used; j++)
- total += bc->dec[j];
-
- fprintf(stderr,
- "Codec %u (DEC): %llu cycles for %u frames => "
- "%llu cycles/frame\n", i, total, bc->dec_used,
- total / bc->dec_used);
+ cycles = osmo_gapk_bench_get_cycles(i, 0);
+ frames = osmo_gapk_bench_get_frames(i, 0);
+
+ fprintf(stderr, "Codec %u (DEC): %llu cycles for %u frames"
+ " => %llu cycles/frame\n", i, cycles,
+ frames, cycles / frames);
}
}
}