History

tests/swscale: print speedup numbers in color

Niklas Haas committed 1 year ago

Commit f438f3f1 parent 995986e1 file · +11 −4Browse files

Unified · Split

libswscale/tests/swscale.c+11−4
@@ -239,10 +239,17 @@ static int run_test(enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt, · 238 unmodified lines
239239 }
240240
241241 if (opts.bench && time_ref) {
242− printf(" time=%"PRId64" us, ref=%"PRId64" us, speedup=%.3fx %s\n",
243− time / opts.iters, time_ref / opts.iters,
244− (double) time_ref / time,
245− time <= time_ref ? "faster" : "\033[1;33mslower\033[0m");
242+ double ratio = (double) time_ref / time;
243+ const char *color = ratio > 1.10 ? "\033[1;32m" : /* bold green */
244+ ratio > 1.02 ? "\033[32m" : /* green */
245+ ratio > 0.98 ? "" : /* default */
246+ ratio > 0.95 ? "\033[33m" : /* yellow */
247+ ratio > 0.90 ? "\033[31m" : /* red */
248+ "\033[1;31m"; /* bold red */
249+
250+ printf(" time=%"PRId64" us, ref=%"PRId64" us, speedup=%.3fx %s%s\033[0m\n",
251+ time / opts.iters, time_ref / opts.iters, ratio, color,
252+ ratio >= 1.0 ? "faster" : "slower");
246253 } else if (opts.bench) {
247254 printf(" time=%"PRId64" us\n", time / opts.iters);
248255 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t