Revision 5727b222 ffmpeg.c

View differences:

ffmpeg.c
26 26
#include <string.h>
27 27
#include <sys/poll.h>
28 28
#include <termios.h>
29
#include <sys/time.h>
30
#include <sys/resource.h>
29 31
#include <ctype.h>
30 32

  
31 33
#include "avformat.h"
......
91 93
static char *str_author = NULL;
92 94
static char *str_copyright = NULL;
93 95
static char *str_comment = NULL;
96
static int do_benchmark = 0;
94 97

  
95 98
typedef struct AVOutputStream {
96 99
    int file_index;          /* file index */
......
1880 1883
    video_codec_id = CODEC_ID_NONE;
1881 1884
}
1882 1885

  
1886
INT64 getutime(void)
1887
{
1888
    struct rusage rusage;
1889

  
1890
    getrusage(RUSAGE_SELF, &rusage);
1891
    return (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
1892
}
1893

  
1883 1894
void show_formats(void)
1884 1895
{
1885 1896
    AVFormat *f;
......
2002 2013
    { "an", OPT_BOOL, {int_arg: &audio_disable}, "disable audio" },
2003 2014
    { "ad", HAS_ARG | OPT_EXPERT, {opt_audio_device}, "set audio device", "device" },
2004 2015
    { "acodec", HAS_ARG | OPT_EXPERT, {opt_audio_codec}, "force audio codec", "codec" },
2016
    { "benchmark", OPT_BOOL | OPT_EXPERT, {int_arg: &do_benchmark}, 
2017
      "add timings for benchmarking" },
2005 2018

  
2006 2019
    { NULL, },
2007 2020
};
......
2057 2070
        }
2058 2071
        av_grab(output_files[0]);
2059 2072
    } else {
2073
        INT64 ti;
2074

  
2060 2075
        if (nb_output_files <= 0) {
2061 2076
            fprintf(stderr, "Must supply at least one output file\n");
2062 2077
            exit(1);
2063 2078
        }
2079
        ti = getutime();
2064 2080
        av_encode(output_files, nb_output_files, input_files, nb_input_files, 
2065 2081
                  stream_maps, nb_stream_maps);
2082
        ti = getutime() - ti;
2083
        if (do_benchmark) {
2084
            printf("bench: utime=%0.3fs\n", ti / 1000000.0);
2085
        }
2066 2086
    }
2067 2087

  
2068 2088
    /* close files */

Also available in: Unified diff