1 /*****************************************************************
2 * gavl - a general purpose audio/video processing library
3 *
4 * Copyright (c) 2001 - 2011 Members of the Gmerlin project
5 * gmerlin-general@lists.sourceforge.net
6 * http://gmerlin.sourceforge.net
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * *****************************************************************/
21
22 #include <sys/time.h>
23 #include <stdlib.h>
24
25 #include <config.h>
26
27 #include <inttypes.h>
28 #include <timeutils.h>
29
30 static struct timeval time_before;
31 static struct timeval time_after;
32
timer_init()33 void timer_init()
34 {
35 gettimeofday(&time_before, NULL);
36 }
37
timer_stop()38 uint64_t timer_stop()
39 {
40 uint64_t before, after, diff;
41
42 gettimeofday(&time_after, NULL);
43
44 before = ((uint64_t)time_before.tv_sec)*1000000 + time_before.tv_usec;
45 after = ((uint64_t)time_after.tv_sec)*1000000 + time_after.tv_usec;
46
47 /* fprintf(stderr, "Before: %f After: %f\n", before, after); */
48
49 diff = after - before;
50
51 return diff;
52
53 }
54
55