diff options
author | Niklas Haas <git@haasn.dev> | 2025-03-04 14:11:07 +0100 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2025-03-31 12:18:35 +0200 |
commit | f438f3f8cd5265ef14895d7996e0d1fd9b36628d (patch) | |
tree | 284958d70a11063d439879f88ecd883bddde4a69 | |
parent | 995986e512d3f18a71aa12e139ba450d1b7205f3 (diff) | |
download | ffmpeg-f438f3f8cd5265ef14895d7996e0d1fd9b36628d.tar.gz |
tests/swscale: print speedup numbers in color
-rw-r--r-- | libswscale/tests/swscale.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c index 516b341eed..a30be077ab 100644 --- a/libswscale/tests/swscale.c +++ b/libswscale/tests/swscale.c @@ -239,10 +239,17 @@ static int run_test(enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt, } if (opts.bench && time_ref) { - printf(" time=%"PRId64" us, ref=%"PRId64" us, speedup=%.3fx %s\n", - time / opts.iters, time_ref / opts.iters, - (double) time_ref / time, - time <= time_ref ? "faster" : "\033[1;33mslower\033[0m"); + double ratio = (double) time_ref / time; + const char *color = ratio > 1.10 ? "\033[1;32m" : /* bold green */ + ratio > 1.02 ? "\033[32m" : /* green */ + ratio > 0.98 ? "" : /* default */ + ratio > 0.95 ? "\033[33m" : /* yellow */ + ratio > 0.90 ? "\033[31m" : /* red */ + "\033[1;31m"; /* bold red */ + + printf(" time=%"PRId64" us, ref=%"PRId64" us, speedup=%.3fx %s%s\033[0m\n", + time / opts.iters, time_ref / opts.iters, ratio, color, + ratio >= 1.0 ? "faster" : "slower"); } else if (opts.bench) { printf(" time=%"PRId64" us\n", time / opts.iters); } |