Skip to content

Commit

Permalink
only allocate space for individual buffer timings if output_all is en…
Browse files Browse the repository at this point in the history
…abled
  • Loading branch information
fps committed May 30, 2022
1 parent aeddb43 commit bac24f0
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions utils/lv2bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,10 @@ bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size)
time_base = 1000000.0;
}

double *elapsed = malloc(sizeof(double) * (sample_count / block_size));
double *elapsed = 0;
if (output_all) {
elapsed = malloc(sizeof(double) * (sample_count / block_size));
}

double elapsed_min = FLT_MAX;
double elapsed_max = 0.f;
Expand All @@ -235,7 +238,9 @@ bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size)
const double elapsed_buffer = bench_end(&ts_buffer);
usleep(10);
elapsed_total += elapsed_buffer;
elapsed[i] = elapsed_buffer;
if (output_all) {
elapsed[i] = elapsed_buffer;
}

if (elapsed_buffer < elapsed_min) elapsed_min = elapsed_buffer;
if (elapsed_buffer > elapsed_max) elapsed_max = elapsed_buffer;
Expand Down Expand Up @@ -269,9 +274,9 @@ bench(const LilvPlugin* p, uint32_t sample_count, uint32_t block_size)
for (uint32_t i = 0; i < (sample_count / block_size); ++i) {
printf("%d %f\n", i, time_base * elapsed[i]);
}
free(elapsed);
}

free(elapsed);
free(buf);
return elapsed_total;
}
Expand Down

0 comments on commit bac24f0

Please sign in to comment.