summaryrefslogtreecommitdiffstats
path: root/src/main.c
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2017-09-04 03:33:48 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2017-12-31 12:20:59 +0100
commit72218e7da04783222f04492d939268ac40585027 (patch)
treea215de5bb42f75c5b37a88fe1bc20c5b9acd3c30 /src/main.c
parentc9a75e59c67d62bc9d64c8c110ef47feb60e7ebf (diff)
benchmark: allocate memory dynamically
Having statically allocated memory for benchmark data of every codec causes high memory usage, especially if actual benchmarking is not required for a particular use case. Instead of that, let's provide an optional opportunity to enable benchmarking for a particular codec by calling the osmo_gapk_bench_enable(). The required amount of memory would be allocated, and then can be freed by calling the osmo_gapk_bench_free() or manually.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index b893f34..623926f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -316,7 +316,7 @@ benchmark_dump(void)
int i, j;
for (i = 0; i < _CODEC_MAX; i++) {
- struct osmo_gapk_bench_cycles *bc = &osmo_gapk_bench_codec[i];
+ struct osmo_gapk_bench_cycles *bc = osmo_gapk_bench_codec[i];
unsigned long long total;
if (bc->enc_used) {
@@ -498,6 +498,9 @@ make_processing_chain(struct gapk_state *gs)
/* Do decoding */
osmo_gapk_pq_queue_codec(gs->pq, codec_in, 0);
+
+ /* Allocate memory for benchmarking */
+ osmo_gapk_bench_enable(fmt_in->codec_type);
}
else if (fmt_in->type != fmt_out->type)
{
@@ -511,6 +514,9 @@ make_processing_chain(struct gapk_state *gs)
/* Do encoding */
osmo_gapk_pq_queue_codec(gs->pq, codec_out, 1);
+ /* Allocate memory for benchmarking */
+ osmo_gapk_bench_enable(fmt_out->codec_type);
+
/* Convert encoder output to output fmt */
if (fmt_out->type != codec_out->codec_enc_format_type)
{
@@ -649,6 +655,9 @@ error:
osmo_gapk_pq_destroy(gs->pq);
benchmark_dump();
+
+ /* Free memory taken by benchmark data */
+ osmo_gapk_bench_free();
return rv;
}