/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/common/timing.c

Go to the documentation of this file.
00001 /* $Id: timing.c,v 1.2 2006/07/27 02:20:56 erg Exp $ $Revision: 1.2 $ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /**********************************************************
00005 *      This software is part of the graphviz package      *
00006 *                http://www.graphviz.org/                 *
00007 *                                                         *
00008 *            Copyright (c) 1994-2004 AT&T Corp.           *
00009 *                and is licensed under the                *
00010 *            Common Public License, Version 1.0           *
00011 *                      by AT&T Corp.                      *
00012 *                                                         *
00013 *        Information and Software Systems Research        *
00014 *              AT&T Research, Florham Park NJ             *
00015 **********************************************************/
00016 
00017 
00018 #ifndef WIN32
00019 
00020 #include        <unistd.h>
00021 #include        <sys/types.h>
00022 #include        <sys/times.h>
00023 #include        <sys/param.h>
00024 #ifndef HZ
00025 #define HZ 60
00026 #endif
00027 typedef struct tms mytime_t;
00028 #define GET_TIME(S) times(&(S))
00029 #define DIFF_IN_SECS(S,T) ((S.tms_utime + S.tms_stime - T.tms_utime - T.tms_stime)/(double)HZ)
00030 
00031 #else
00032 
00033 #include        <time.h>
00034 typedef clock_t mytime_t;
00035 #define GET_TIME(S) S = clock()
00036 #define DIFF_IN_SECS(S,T) ((S - T) / (double)CLOCKS_PER_SEC)
00037 
00038 #endif
00039 
00040 
00041 static mytime_t T;
00042 
00043 void start_timer(void)
00044 {
00045     GET_TIME(T);
00046 }
00047 
00048 double elapsed_sec(void)
00049 {
00050     mytime_t S;
00051     double rv;
00052 
00053     GET_TIME(S);
00054     rv = DIFF_IN_SECS(S, T);
00055     return rv;
00056 }

Generated on Mon Mar 31 19:03:25 2008 for Graphviz by  doxygen 1.5.1