00001 /* 00002 * now.h - some simple minded time measurement support for nana. 00003 * 00004 * Copyright (c) 1997 Phil Maker 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 2. Redistributions in binary form must reproduce the above copyright 00013 * notice, this list of conditions and the following disclaimer in the 00014 * documentation and/or other materials provided with the distribution. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 00017 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00019 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 00020 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00021 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00022 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00023 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00024 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00025 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00026 * SUCH DAMAGE. 00027 * 00028 * Id: now.h,v 1.2 1998/07/08 10:56:12 pjm Exp 00029 */ 00030 00031 00032 #ifndef _now_h_ 00033 #define _now_h_ 1 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 /* 00040 * now() - returns the current real time in seconds from the wallclock 00041 * using gettimeofday(2). Accuracy (quoted from IPM documentation) is: 00042 * 00043 * SUNOS 4 and 5, HPUX approx 1us 00044 * Linux approx 100us 00045 * SGI, AIX approx 10ms 00046 * 00047 * If you need something a bit faster try either the cycles.h library 00048 * or use $cycles in the simulator. 00049 */ 00050 00051 double now(void); 00052 00053 /* 00054 * now_reset() - resets the values returned by now() back to 0 so that 00055 * the values are a little smaller. You might use this as part of your 00056 * initialisation sequence to make time values easier to read (e.g. 00057 * 123.4566 rather than 81828282.8888) 00058 */ 00059 00060 void now_reset(void); 00061 00062 /* 00063 * now_delta(t) - used to make a delta time counter, the argument is the 00064 * used to record the last event we are measuring the time from. 00065 * 00066 * t = now(); ...; now_delta(&t); ...; now_delta(&t); ... 00067 * 00068 */ 00069 00070 double now_delta(double *t); 00071 00072 #ifdef __cplusplus 00073 } 00074 #endif 00075 00076 #endif /* _now_h_ */ 00077
1.3.4