4 * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
6 * This file is part of libFirm.
8 * This file may be distributed and/or modified under the terms of the
9 * GNU General Public License version 2 as published by the Free Software
10 * Foundation and appearing in the file LICENSE.GPL included in the
11 * packaging of this file.
13 * Licensees holding valid libFirm Professional Edition licenses may use
14 * this file in accordance with the libFirm Commercial License.
15 * Agreement provided with the Software.
17 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 * @brief generic timing routines
26 * @date Mon 18 Oct 2004
29 * Timing stuff. Not really part of ana2, but where else should it go.
43 struct timeval *start;
49 timing_t *start_timing (void) {}
50 int end_timing (timing_t *t) {}
60 timeval_subtract (struct timeval *x, struct timeval *y)
62 /* Perform the carry for the later subtraction by updating Y. */
63 if (x->tv_usec < y->tv_usec) {
64 int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
65 y->tv_usec -= 1000000 * nsec;
69 if (x->tv_usec - y->tv_usec > 1000000) {
70 int nsec = (x->tv_usec - y->tv_usec) / 1000000;
71 y->tv_usec += 1000000 * nsec;
75 return ((x->tv_sec - y->tv_sec) * 1000000 + (x->tv_usec - y->tv_usec));
85 timing_t *t = (timing_t*) xmalloc (sizeof (timing_t));
87 t->start = (struct timeval*) xmalloc (sizeof (struct timeval));
88 t->end = (struct timeval*) xmalloc (sizeof (struct timeval));
90 gettimeofday (t->start, NULL);
96 end_timing (timing_t *t)
100 gettimeofday (t->end, NULL);
102 time = timeval_subtract (t->end, t->start);
104 memset (t->start, 0x0, sizeof (struct timeval));
107 memset (t->end, 0x0, sizeof (struct timeval));
110 memset (t, 0x00, sizeof (timing_t));
120 Revision 1.5 2006/09/12 12:17:37 matze
123 Revision 1.4 2006/06/06 12:06:27 beck
124 use xmalloc instead of malloc
126 Revision 1.3 2005/01/05 14:25:38 beck
127 added Win32 "support"
129 Revision 1.2 2004/12/21 15:52:23 beck
130 moved struct timing_env to .c file, added config.h
132 Revision 1.1 2004/10/29 18:55:52 liekweg
133 (mostly) generic timimg