[FFmpeg-cvslog] r21973 - in trunk: configure doc/ffmpeg-doc.texi ffmpeg.c

reimar subversion
Mon Feb 22 23:21:58 CET 2010


Author: reimar
Date: Mon Feb 22 23:21:58 2010
New Revision: 21973

Log:
Make -benchmark also print the maximum memory usage if possible.

Modified:
   trunk/configure
   trunk/doc/ffmpeg-doc.texi
   trunk/ffmpeg.c

Modified: trunk/configure
==============================================================================
--- trunk/configure	Mon Feb 22 23:05:20 2010	(r21972)
+++ trunk/configure	Mon Feb 22 23:21:58 2010	(r21973)
@@ -1028,8 +1028,10 @@ HAVE_LIST="
     fork
     getaddrinfo
     gethrtime
+    GetProcessMemoryInfo
     GetProcessTimes
     getrusage
+    struct_rusage_ru_maxrss
     inet_aton
     inline_asm
     isatty
@@ -2497,6 +2499,7 @@ check_func  fork
 check_func  getaddrinfo $network_extralibs
 check_func  gethrtime
 check_func  getrusage
+check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
 check_func  inet_aton $network_extralibs
 check_func  isatty
 check_func  ${malloc_prefix}memalign            && enable memalign
@@ -2505,6 +2508,7 @@ check_func  ${malloc_prefix}posix_memali
 check_func  setrlimit
 check_func_headers io.h setmode
 check_func_headers lzo/lzo1x.h lzo1x_999_compress
+check_lib2 "windows.h psapi.h" GetProcessMemoryInfo -lpsapi
 check_func_headers windows.h GetProcessTimes
 check_func_headers windows.h VirtualAlloc
 

Modified: trunk/doc/ffmpeg-doc.texi
==============================================================================
--- trunk/doc/ffmpeg-doc.texi	Mon Feb 22 23:05:20 2010	(r21972)
+++ trunk/doc/ffmpeg-doc.texi	Mon Feb 22 23:21:58 2010	(r21973)
@@ -734,7 +734,10 @@ Set meta data information of @var{outfil
 @item -debug
 Print specific debug info.
 @item -benchmark
-Add timings for benchmarking.
+Show benchmarking information at the end of an encode.
+Shows CPU time used and maximum memory consumption.
+Maximum memory consumption is not supported on all systems,
+it will usually display as 0 if not supported.
 @item -dump
 Dump each input packet.
 @item -hex

Modified: trunk/ffmpeg.c
==============================================================================
--- trunk/ffmpeg.c	Mon Feb 22 23:05:20 2010	(r21972)
+++ trunk/ffmpeg.c	Mon Feb 22 23:21:58 2010	(r21973)
@@ -44,10 +44,15 @@
 
 #if HAVE_SYS_RESOURCE_H
 #include <sys/types.h>
+#include <sys/time.h>
 #include <sys/resource.h>
 #elif HAVE_GETPROCESSTIMES
 #include <windows.h>
 #endif
+#if HAVE_GETPROCESSMEMORYINFO
+#include <windows.h>
+#include <psapi.h>
+#endif
 
 #if HAVE_SYS_SELECT_H
 #include <sys/select.h>
@@ -3535,6 +3540,24 @@ static int64_t getutime(void)
 #endif
 }
 
+static int64_t getmaxrss(void)
+{
+#if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
+    struct rusage rusage;
+    getrusage(RUSAGE_SELF, &rusage);
+    return (int64_t)rusage.ru_maxrss * 1024;
+#elif HAVE_GETPROCESSMEMORYINFO
+    HANDLE proc;
+    PROCESS_MEMORY_COUNTERS memcounters;
+    proc = GetCurrentProcess();
+    memcounters.cb = sizeof(memcounters);
+    GetProcessMemoryInfo(proc, &memcounters, sizeof(memcounters));
+    return memcounters.PeakPagefileUsage;
+#else
+    return 0;
+#endif
+}
+
 static void parse_matrix_coeffs(uint16_t *dest, const char *str)
 {
     int i;
@@ -4029,7 +4052,8 @@ int main(int argc, char **argv)
         av_exit(1);
     ti = getutime() - ti;
     if (do_benchmark) {
-        printf("bench: utime=%0.3fs\n", ti / 1000000.0);
+        int maxrss = getmaxrss() / 1024;
+        printf("bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss);
     }
 
     return av_exit(0);



More information about the ffmpeg-cvslog mailing list