|
Graphviz
2.29.20120524.0446
|
00001 /* $Id$ $Revision$ */ 00002 /* vim:set shiftwidth=4 ts=8: */ 00003 00004 /************************************************************************* 00005 * Copyright (c) 2011 AT&T Intellectual Property 00006 * All rights reserved. This program and the accompanying materials 00007 * are made available under the terms of the Eclipse Public License v1.0 00008 * which accompanies this distribution, and is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * 00011 * Contributors: See CVS logs. Details at http://www.graphviz.org/ 00012 *************************************************************************/ 00013 00014 #ifndef WIN32 00015 00016 #include <unistd.h> 00017 #include <sys/types.h> 00018 #include <sys/times.h> 00019 #include <sys/param.h> 00020 00021 00022 00023 #ifndef HZ 00024 #define HZ 60 00025 #endif 00026 typedef struct tms mytime_t; 00027 #define GET_TIME(S) times(&(S)) 00028 #define DIFF_IN_SECS(S,T) ((S.tms_utime + S.tms_stime - T.tms_utime - T.tms_stime)/(double)HZ) 00029 00030 #else 00031 00032 #include <time.h> 00033 #include "render.h" 00034 #include "utils.h" 00035 00036 typedef clock_t mytime_t; 00037 #define GET_TIME(S) S = clock() 00038 #define DIFF_IN_SECS(S,T) ((S - T) / (double)CLOCKS_PER_SEC) 00039 00040 #endif 00041 00042 00043 static mytime_t T; 00044 00045 void start_timer(void) 00046 { 00047 GET_TIME(T); 00048 } 00049 00050 double elapsed_sec(void) 00051 { 00052 mytime_t S; 00053 double rv; 00054 00055 GET_TIME(S); 00056 rv = DIFF_IN_SECS(S, T); 00057 return rv; 00058 }
1.7.5