aboutsummaryrefslogtreecommitdiffstats
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>2010-02-22 22:21:58 +0000
committerReimar Döffinger <Reimar.Doeffinger@gmx.de>2010-02-22 22:21:58 +0000
commitfc5607f86209b0a0ddec1b0a3816f7977e15f516 (patch)
treede1f30ffd0cc6add56360a4fe1f870525485f561 /ffmpeg.c
parentb7884740fa2157c6d2a337012370c460e728d299 (diff)
downloadffmpeg-fc5607f86209b0a0ddec1b0a3816f7977e15f516.tar.gz
Make -benchmark also print the maximum memory usage if possible.
Originally committed as revision 21973 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index cb53bfc715..654e7e666a 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -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);