git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/Rgraphviz@88840 bc3139a8-67e5-0310-9ffc-ced21a209358
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,58 @@ |
1 |
+/* $Id: timing.c,v 1.9 2011/01/25 16:30:48 ellson Exp $ $Revision: 1.9 $ */ |
|
2 |
+/* vim:set shiftwidth=4 ts=8: */ |
|
3 |
+ |
|
4 |
+/************************************************************************* |
|
5 |
+ * Copyright (c) 2011 AT&T Intellectual Property |
|
6 |
+ * All rights reserved. This program and the accompanying materials |
|
7 |
+ * are made available under the terms of the Eclipse Public License v1.0 |
|
8 |
+ * which accompanies this distribution, and is available at |
|
9 |
+ * http://www.eclipse.org/legal/epl-v10.html |
|
10 |
+ * |
|
11 |
+ * Contributors: See CVS logs. Details at http://www.graphviz.org/ |
|
12 |
+ *************************************************************************/ |
|
13 |
+ |
|
14 |
+#ifndef WIN32 |
|
15 |
+ |
|
16 |
+#include <unistd.h> |
|
17 |
+#include <sys/types.h> |
|
18 |
+#include <sys/times.h> |
|
19 |
+#include <sys/param.h> |
|
20 |
+ |
|
21 |
+ |
|
22 |
+ |
|
23 |
+#ifndef HZ |
|
24 |
+#define HZ 60 |
|
25 |
+#endif |
|
26 |
+typedef struct tms mytime_t; |
|
27 |
+#define GET_TIME(S) times(&(S)) |
|
28 |
+#define DIFF_IN_SECS(S,T) ((S.tms_utime + S.tms_stime - T.tms_utime - T.tms_stime)/(double)HZ) |
|
29 |
+ |
|
30 |
+#else |
|
31 |
+ |
|
32 |
+#include <time.h> |
|
33 |
+#include "render.h" |
|
34 |
+#include "utils.h" |
|
35 |
+ |
|
36 |
+typedef clock_t mytime_t; |
|
37 |
+#define GET_TIME(S) S = clock() |
|
38 |
+#define DIFF_IN_SECS(S,T) ((S - T) / (double)CLOCKS_PER_SEC) |
|
39 |
+ |
|
40 |
+#endif |
|
41 |
+ |
|
42 |
+ |
|
43 |
+static mytime_t T; |
|
44 |
+ |
|
45 |
+void start_timer(void) |
|
46 |
+{ |
|
47 |
+ GET_TIME(T); |
|
48 |
+} |
|
49 |
+ |
|
50 |
+double elapsed_sec(void) |
|
51 |
+{ |
|
52 |
+ mytime_t S; |
|
53 |
+ double rv; |
|
54 |
+ |
|
55 |
+ GET_TIME(S); |
|
56 |
+ rv = DIFF_IN_SECS(S, T); |
|
57 |
+ return rv; |
|
58 |
+} |