From patchwork Fri Apr 27 17:31:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wachsler X-Patchwork-Id: 8670 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp893360jad; Fri, 27 Apr 2018 10:39:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp9ZfvpJlcvKnKLds2vKZdzIFX3D3kdScPRTzFPoY4XbwdN+xR79uvFR4haVKU4ONxJDVDz X-Received: by 10.28.175.75 with SMTP id y72mr1968634wme.148.1524850748636; Fri, 27 Apr 2018 10:39:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524850748; cv=none; d=google.com; s=arc-20160816; b=B9bd/7yUyiJzjK3hTVMqPcj7f4q4jpgi2HuNyt1DZtJ0ITOd6TdL9yuxWrZ64Esslf O9PCnCWI1Y29nMNk4AgBSAp412YtHvHRr1zjTG88u5BjYZn1wcA/apx4MncH1zyerNU2 blrMl68/6ZJIFpPEKDBSiIlmwo1TopIU/a8Q3VhX4qHNZx85TSlPR+baWgC2EpVZG6wq F+FK/PkrGc7mVUmMYCQv1CKZdpz4AxsN4Q50I9Ut72dsLprBwUPAq8+zmzwQloPT/p0u 7CeaeF9yBbSdUQJLN8P1YgxbUJgNfd39IwkOzXy7E8mdhAWo0wLZO1wR2xQL3z8wPa4f +s3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=XriC8OniwOAs3VIXr/jRo5p+r7+PX5liaDkA/hFSFb8=; b=qJ28vDG1ZELxiOXA5I3oVRnWVkkpFYc6S4xnhkTHzxcFvNWMXu8Z7yCBhUl+ysvxuh Nln2HkJZoeXFps9WDtttvP7enroTIfrlHckD77yonq1GR3ePK2tR5CMYJaOrbILavmrO StmYh9Mn3SAy7BceGD6yfbtJEh8RWmK8ME4PYol0GaSgjrqjNfEzZRZUttAuu3/j4qVM S6e0BraPvRu7gaVovgUiaxODQQisjKLOjWxIhaNk2EYb+B8alCbtggKgevuFtCkydpaR vPJcljXJMTJGhGXPHRN/DTz+g9t3fH7IWhc6iPP5gYe6GS8jPpakhZrhc78cCQ/+Ecwq OkTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=Ru9gJTLr; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n5-v6si1570828wrm.95.2018.04.27.10.39.08; Fri, 27 Apr 2018 10:39:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=Ru9gJTLr; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2F8BF68A5B0; Fri, 27 Apr 2018 20:38:36 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3DC5368A4CF for ; Fri, 27 Apr 2018 20:38:29 +0300 (EEST) Received: by mail-qk0-f194.google.com with SMTP id b39so2015378qkb.5 for ; Fri, 27 Apr 2018 10:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zekk7bmVvU8RlEN2KiaHvHyY5bhvcM2pDNMYDQd77wc=; b=Ru9gJTLr9PjLnUjommt2raJWoTYwk1LdAM9Yd8f10iOUea7h0WkoVFnqjkBzdK/9TD jxuYOl4WeTt46B/9pxNNsvqSxHQY9MKhR/SspSEQygz1IQ+kFVc8Lps8shQP1Au5HeEx ZQ/WvtrPDqIn07TSH4GWIvgVbrU2upzGgaxr//mfJxDzYRd0TJtJOmyUtvcMBKTZodu7 kdrSX4W1Z5Q2x6UhCB2J+Q83FbNtsDxQZ/L0yejGZusCcDbHKxS+qlRA4eiag19A3WEN 5D3TSUN/peZUOkTnmxbSTexA42mAs9SYhs2j6hQcn3gHUOrcpGhjGE0OFLhiJYVBO7nB 6yQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zekk7bmVvU8RlEN2KiaHvHyY5bhvcM2pDNMYDQd77wc=; b=Bv88lOv2hEyqpFiohNaEhkueM+hyd6RIIjCQ6Q5uLSiTXGgbOwurHw9z5pYKrupqJF tlbyl0NBrWyMK75INHMkjvf3mktW/ni3t5J4FGMfMeoJ13STiVlUZpmTcSZ5t4+kJ4oY lxDmroXjh8ImrJXjzH5QKmQAruvqGA3YAUitiZxH9H0+KgBu6CRo1EYcWpwZyfCCIM8T RiVCf9Pncj/+K6ilRBSmv040BnZw2+rju7Xvv6raSA3mzoxCFXyEto0HuONT6x8rTi0U J19J0S1Xst+Dq4kkN9JcYZlexA1Ilnk0jAs68VgnAYE/7j8oFZPkjUGsBQbo8nEOiqWO 8RmA== X-Gm-Message-State: ALQs6tBcXwoCjsDjK9R2Hg1g5FbP3PQhXWSZ/OLTp0LivlRfRHNghxGV 5DKJSEXeg8j6WTT3YbqH7ubdMpFuR/g= X-Received: by 10.55.163.203 with SMTP id m194mr2740246qke.339.1524850399782; Fri, 27 Apr 2018 10:33:19 -0700 (PDT) Received: from quechee.cam.corp.google.com ([100.67.2.16]) by smtp.gmail.com with ESMTPSA id b190sm1380228qka.2.2018.04.27.10.33.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 Apr 2018 10:33:19 -0700 (PDT) From: Mark Wachsler To: ffmpeg-devel@ffmpeg.org Date: Fri, 27 Apr 2018 13:31:59 -0400 Message-Id: <20180427173159.77340-1-wachsler@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180427163157.GN20131@michaelspb> References: <20180427163157.GN20131@michaelspb> Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg: Add system time and real time to benchmarking. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Mark Wachsler MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The -benchmark and -benchmark_all options now show user, system, and real time, instead of just user time. --- fftools/ffmpeg.c | 49 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 4dbe72186d..4036058591 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -120,8 +120,14 @@ const char *const forced_keyframes_const_names[] = { NULL }; +typedef struct BenchmarkTimeStamps { + int64_t real_usec; + int64_t user_usec; + int64_t sys_usec; +} BenchmarkTimeStamps; + static void do_video_stats(OutputStream *ost, int frame_size); -static int64_t getutime(void); +static BenchmarkTimeStamps get_benchmark_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 BenchmarkTimeStamps 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(); + BenchmarkTimeStamps t = get_benchmark_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,31 @@ static int transcode(void) return ret; } - -static int64_t getutime(void) +static BenchmarkTimeStamps get_benchmark_time_stamps(void) { + BenchmarkTimeStamps time_stamps; + time_stamps.real_usec = av_gettime_relative(); #if HAVE_GETRUSAGE struct rusage rusage; getrusage(RUSAGE_SELF, &rusage); - return (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec; + time_stamps.user_usec = + (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec; + time_stamps.sys_usec = + (rusage.ru_stime.tv_sec * 1000000LL) + rusage.ru_stime.tv_usec; #elif HAVE_GETPROCESSTIMES HANDLE proc; FILETIME c, e, k, u; proc = GetCurrentProcess(); GetProcessTimes(proc, &c, &e, &k, &u); - return ((int64_t) u.dwHighDateTime << 32 | u.dwLowDateTime) / 10; + time_stamps.user_usec = + ((int64_t)u.dwHighDateTime << 32 | u.dwLowDateTime) / 10; + time_stamps.sys_usec = + ((int64_t)k.dwHighDateTime << 32 | k.dwLowDateTime) / 10; #else - return av_gettime_relative(); + time_stamps.user_usec = time_stamps.sys_usec = 0; #endif + return time_stamps; } static int64_t getmaxrss(void) @@ -4759,7 +4777,7 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl) int main(int argc, char **argv) { int i, ret; - int64_t ti; + BenchmarkTimeStamps ti; init_dynload(); @@ -4811,12 +4829,17 @@ int main(int argc, char **argv) want_sdp = 0; } - current_time = ti = getutime(); + current_time = ti = get_benchmark_time_stamps(); if (transcode() < 0) exit_program(1); - ti = getutime() - ti; if (do_benchmark) { - av_log(NULL, AV_LOG_INFO, "bench: utime=%0.3fs\n", ti / 1000000.0); + current_time = get_benchmark_time_stamps(); + int64_t utime = current_time.user_usec - ti.user_usec; + int64_t stime = current_time.sys_usec - ti.sys_usec; + int64_t rtime = current_time.real_usec - ti.real_usec; + av_log(NULL, AV_LOG_INFO, + "bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n", + utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0); } av_log(NULL, AV_LOG_DEBUG, "%"PRIu64" frames successfully decoded, %"PRIu64" decoding errors\n", decode_error_stat[0], decode_error_stat[1]);