4 * Time-stamp: <26.10.2004 11:57:13h liekweg>
6 * File name: ir/ana2/timing.c
7 * Purpose: generic timing routines
10 * Created: Mon 18 Oct 2004
12 * Copyright: (c) 1999-2004 Universität Karlsruhe
13 * Licence: This file is protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 Timing stuff. Not really part of ana2, but where else should it go.
30 struct timeval *start;
36 timing_t *start_timing (void) {}
37 int end_timing (timing_t *t) {}
47 timeval_subtract (struct timeval *x, struct timeval *y)
49 /* Perform the carry for the later subtraction by updating Y. */
50 if (x->tv_usec < y->tv_usec) {
51 int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
52 y->tv_usec -= 1000000 * nsec;
56 if (x->tv_usec - y->tv_usec > 1000000) {
57 int nsec = (x->tv_usec - y->tv_usec) / 1000000;
58 y->tv_usec += 1000000 * nsec;
62 return ((x->tv_sec - y->tv_sec) * 1000000 + (x->tv_usec - y->tv_usec));
72 timing_t *t = (timing_t*) malloc (sizeof (timing_t));
74 t->start = (struct timeval*) malloc (sizeof (struct timeval));
75 t->end = (struct timeval*) malloc (sizeof (struct timeval));
77 gettimeofday (t->start, NULL);
83 end_timing (timing_t *t)
87 gettimeofday (t->end, NULL);
89 time = timeval_subtract (t->end, t->start);
91 memset (t->start, 0x0, sizeof (struct timeval));
94 memset (t->end, 0x0, sizeof (struct timeval));
97 memset (t, 0x00, sizeof (timing_t));
107 Revision 1.3 2005/01/05 14:25:38 beck
108 added Win32 "support"
110 Revision 1.2 2004/12/21 15:52:23 beck
111 moved struct timing_env to .c file, added config.h
113 Revision 1.1 2004/10/29 18:55:52 liekweg
114 (mostly) generic timimg