[FFmpeg-devel] [PATCH] Add system and real time to benchmarking.

Michael Niedermayer michael at niedermayer.cc
Fri Apr 27 19:31:57 EEST 2018


On Fri, Apr 20, 2018 at 04:21:13PM -0400, Mark Wachsler wrote:
> The -benchmark and -benchmark_all options now show user, system, and real time,
> instead of just user time.
> ---
>  fftools/ffmpeg.c | 50 ++++++++++++++++++++++++++++++++++--------------
>  1 file changed, 36 insertions(+), 14 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 4dbe72186d..d37171d567 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -120,8 +120,14 @@ const char *const forced_keyframes_const_names[] = {
>      NULL
>  };
>  
> +typedef struct TimeStamps {
> +  int64_t real_usec;
> +  int64_t user_usec;
> +  int64_t sys_usec;
> +} TimeStamps;

indention mismatches the rest of the file

also please use some other name, time stamps exist in many areas
of multimedia. This is benchmarking specific. "Benchmark" should be
part of the name to seperate it from other time uses


> +
>  static void do_video_stats(OutputStream *ost, int frame_size);
> -static int64_t getutime(void);
> +static TimeStamps get_time_stamps(void);
>  static int64_t getmaxrss(void);
>  static int ifilter_has_all_input_formats(FilterGraph *fg);
>  
> @@ -133,7 +139,7 @@ static int64_t decode_error_stat[2];
>  
>  static int want_sdp = 1;
>  
> -static int current_time;
> +static TimeStamps current_time;
>  AVIOContext *progress_avio = NULL;
>  
>  static uint8_t *subtitle_out;
> @@ -653,7 +659,7 @@ static void abort_codec_experimental(AVCodec *c, int encoder)
>  static void update_benchmark(const char *fmt, ...)
>  {
>      if (do_benchmark_all) {
> -        int64_t t = getutime();
> +        TimeStamps t = get_time_stamps();
>          va_list va;
>          char buf[1024];
>  
> @@ -661,7 +667,11 @@ static void update_benchmark(const char *fmt, ...)
>              va_start(va, fmt);
>              vsnprintf(buf, sizeof(buf), fmt, va);
>              va_end(va);
> -            av_log(NULL, AV_LOG_INFO, "bench: %8"PRIu64" %s \n", t - current_time, buf);
> +            av_log(NULL, AV_LOG_INFO,
> +                   "bench: %8" PRIu64 " user %8" PRIu64 " sys %8" PRIu64 " real %s \n",
> +                   t.user_usec - current_time.user_usec,
> +                   t.sys_usec - current_time.sys_usec,
> +                   t.real_usec - current_time.real_usec, buf);
>          }
>          current_time = t;
>      }

> @@ -4715,23 +4725,30 @@ static int transcode(void)
>      return ret;
>  }
>  
> -
> -static int64_t getutime(void)
> -{
> +static TimeStamps get_time_stamps(void) {
> +  TimeStamps time_stamps;
> +  time_stamps.real_usec = av_gettime_relative();

again, indention mismatches, also the { placement mismatches other functions
(i dont mind really much personally, but some people are sensitive about this)

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180427/11c32350/attachment.sig>


More information about the ffmpeg-devel mailing list