From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH 06/11] tests/swscale: print performance stats on exit
Date: Mon, 17 Mar 2025 11:43:52 +0100
Message-ID: <20250317104357.307832-6-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20250317104357.307832-1-ffmpeg@haasn.xyz>
From: Niklas Haas <git@haasn.dev>
---
libswscale/tests/swscale.c | 47 ++++++++++++++++++++++++++++++--------
1 file changed, 38 insertions(+), 9 deletions(-)
diff --git a/libswscale/tests/swscale.c b/libswscale/tests/swscale.c
index ea6c57ff2a..a2b960faa3 100644
--- a/libswscale/tests/swscale.c
+++ b/libswscale/tests/swscale.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <inttypes.h>
#include <stdarg.h>
+#include <signal.h>
#undef HAVE_AV_CONFIG_H
#include "libavutil/cpu.h"
@@ -71,6 +72,33 @@ const SwsFlags flags[] = {
static FFSFC64 prng_state;
static SwsContext *sws[3]; /* reused between tests for efficiency */
+static double speedup_logavg;
+static double speedup_min = 1e10;
+static double speedup_max = 0;
+static int speedup_count;
+
+static const char *speedup_color(double ratio)
+{
+ return 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 */
+}
+
+static void exit_handler(int sig)
+{
+ if (speedup_count) {
+ double ratio = exp(speedup_logavg / speedup_count);
+ printf("Overall speedup=%.3fx %s%s\033[0m, min=%.3fx max=%.3fx\n", ratio,
+ speedup_color(ratio), ratio >= 1.0 ? "faster" : "slower",
+ speedup_min, speedup_max);
+ }
+
+ exit(sig);
+}
+
static int fmt_comps(enum AVPixelFormat fmt)
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(fmt);
@@ -261,16 +289,16 @@ static int run_test(enum AVPixelFormat src_fmt, enum AVPixelFormat dst_fmt,
if (opts.bench && time_ref) {
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 */
+ if (FFMIN(time, time_ref) > 100 /* don't pollute stats with low precision */) {
+ speedup_min = FFMIN(speedup_min, ratio);
+ speedup_max = FFMAX(speedup_max, ratio);
+ speedup_logavg += log(ratio);
+ speedup_count++;
+ }
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");
+ time / opts.iters, time_ref / opts.iters, ratio,
+ speedup_color(ratio), ratio >= 1.0 ? "faster" : "slower");
} else if (opts.bench) {
printf(" time=%"PRId64" us\n", time / opts.iters);
}
@@ -492,6 +520,7 @@ bad_option:
ff_sfc64_init(&prng_state, 0, 0, 0, 12);
av_lfg_init(&rand, 1);
+ signal(SIGINT, exit_handler);
for (int i = 0; i < 3; i++) {
sws[i] = sws_alloc_context();
@@ -537,5 +566,5 @@ error:
av_frame_free(&ref);
if (fp)
fclose(fp);
- return ret;
+ exit_handler(ret);
}
--
2.48.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2025-03-17 10:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 10:43 [FFmpeg-devel] [PATCH 01/11] tests/swscale: allow choosing specific flags and dither mode Niklas Haas
2025-03-17 10:43 ` [FFmpeg-devel] [PATCH 02/11] tests/swscale: allow testing only unscaled convertors Niklas Haas
2025-03-17 10:43 ` [FFmpeg-devel] [PATCH 03/11] tests/swscale: print speedup numbers in color Niklas Haas
2025-03-17 10:43 ` [FFmpeg-devel] [PATCH 04/11] tests/swscale: use yuva444p as reference Niklas Haas
2025-03-17 10:43 ` [FFmpeg-devel] [PATCH 05/11] tests/swscale: switch from MSE to SSIM Niklas Haas
2025-03-17 10:43 ` Niklas Haas [this message]
2025-03-17 10:43 ` [FFmpeg-devel] [PATCH 07/11] tests/swscale: check supported inputs for legacy swscale separately Niklas Haas
2025-03-17 10:43 ` [FFmpeg-devel] [PATCH 08/11] tests/swscale: remove stray whitespace in scanf format Niklas Haas
2025-03-17 10:43 ` [FFmpeg-devel] [PATCH 09/11] tests/swscale: calculate theoretical expected SSIM Niklas Haas
2025-03-17 10:53 ` Niklas Haas
2025-03-17 10:43 ` [FFmpeg-devel] [PATCH 10/11] tests/swscale: constrain reference SSIM for low bit depth formats Niklas Haas
2025-03-17 10:43 ` [FFmpeg-devel] [PATCH 11/11] tests/swscale: allow setting log verbosity Niklas Haas
2025-03-24 11:44 ` [FFmpeg-devel] [PATCH 01/11] tests/swscale: allow choosing specific flags and dither mode Niklas Haas
2025-03-25 12:19 ` Ramiro Polla
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250317104357.307832-6-ffmpeg@haasn.xyz \
--to=ffmpeg@haasn.xyz \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=git@haasn.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git