Add option to only print directory totals
This commit is contained in:
parent
f45f47c9f0
commit
66d12eb078
13
qoibench.c
13
qoibench.c
@ -320,6 +320,7 @@ int opt_noverify = 0;
|
|||||||
int opt_nodecode = 0;
|
int opt_nodecode = 0;
|
||||||
int opt_noencode = 0;
|
int opt_noencode = 0;
|
||||||
int opt_norecurse = 0;
|
int opt_norecurse = 0;
|
||||||
|
int opt_onlytotals = 0;
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -411,6 +412,7 @@ benchmark_result_t benchmark_image(const char *path) {
|
|||||||
int h;
|
int h;
|
||||||
|
|
||||||
// Load the encoded PNG, encoded QOI and raw pixels into memory
|
// Load the encoded PNG, encoded QOI and raw pixels into memory
|
||||||
|
|
||||||
void *pixels = (void *)stbi_load(path, &w, &h, NULL, 4);
|
void *pixels = (void *)stbi_load(path, &w, &h, NULL, 4);
|
||||||
void *encoded_png = fload(path, &encoded_png_size);
|
void *encoded_png = fload(path, &encoded_png_size);
|
||||||
void *encoded_qoi = qoi_encode(pixels, &(qoi_desc){
|
void *encoded_qoi = qoi_encode(pixels, &(qoi_desc){
|
||||||
@ -425,6 +427,7 @@ benchmark_result_t benchmark_image(const char *path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Verify QOI Output
|
// Verify QOI Output
|
||||||
|
|
||||||
if (!opt_noverify) {
|
if (!opt_noverify) {
|
||||||
qoi_desc dc;
|
qoi_desc dc;
|
||||||
void *pixels_qoi = qoi_decode(encoded_qoi, encoded_qoi_size, &dc, 4);
|
void *pixels_qoi = qoi_decode(encoded_qoi, encoded_qoi_size, &dc, 4);
|
||||||
@ -434,6 +437,8 @@ benchmark_result_t benchmark_image(const char *path) {
|
|||||||
free(pixels_qoi);
|
free(pixels_qoi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
benchmark_result_t res = {0};
|
benchmark_result_t res = {0};
|
||||||
res.count = 1;
|
res.count = 1;
|
||||||
res.raw_size = w * h * 4;
|
res.raw_size = w * h * 4;
|
||||||
@ -549,8 +554,10 @@ void benchmark_directory(const char *path, benchmark_result_t *grand_total) {
|
|||||||
|
|
||||||
benchmark_result_t res = benchmark_image(file_path);
|
benchmark_result_t res = benchmark_image(file_path);
|
||||||
|
|
||||||
printf("## %s size: %dx%d\n", file_path, res.w, res.h);
|
if (!opt_onlytotals) {
|
||||||
benchmark_print_result(res);
|
printf("## %s size: %dx%d\n", file_path, res.w, res.h);
|
||||||
|
benchmark_print_result(res);
|
||||||
|
}
|
||||||
|
|
||||||
free(file_path);
|
free(file_path);
|
||||||
|
|
||||||
@ -598,6 +605,7 @@ int main(int argc, char **argv) {
|
|||||||
printf(" --noencode ... don't run encoders\n");
|
printf(" --noencode ... don't run encoders\n");
|
||||||
printf(" --nodecode ... don't run decoders\n");
|
printf(" --nodecode ... don't run decoders\n");
|
||||||
printf(" --norecurse .. don't descend into directories\n");
|
printf(" --norecurse .. don't descend into directories\n");
|
||||||
|
printf(" --onlytotals . don't print individual image results\n");
|
||||||
printf("Examples\n");
|
printf("Examples\n");
|
||||||
printf(" qoibench 10 images/textures/\n");
|
printf(" qoibench 10 images/textures/\n");
|
||||||
printf(" qoibench 1 images/textures/ --nopng --nowarmup\n");
|
printf(" qoibench 1 images/textures/ --nopng --nowarmup\n");
|
||||||
@ -611,6 +619,7 @@ int main(int argc, char **argv) {
|
|||||||
else if (strcmp(argv[i], "--noencode") == 0) { opt_noencode = 1; }
|
else if (strcmp(argv[i], "--noencode") == 0) { opt_noencode = 1; }
|
||||||
else if (strcmp(argv[i], "--nodecode") == 0) { opt_nodecode = 1; }
|
else if (strcmp(argv[i], "--nodecode") == 0) { opt_nodecode = 1; }
|
||||||
else if (strcmp(argv[i], "--norecurse") == 0) { opt_norecurse = 1; }
|
else if (strcmp(argv[i], "--norecurse") == 0) { opt_norecurse = 1; }
|
||||||
|
else if (strcmp(argv[i], "--onlytotals") == 0) { opt_onlytotals = 1; }
|
||||||
else { ERROR("Unknown option %s", argv[i]); }
|
else { ERROR("Unknown option %s", argv[i]); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user