FreeCalypso > hg > freecalypso-reveng
comparison fluid-mnf/misc.c @ 356:00060bb8b240
fluid-mnf/misc.c: fixed stopwatch functions for Unix
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 13 Mar 2020 20:47:37 +0000 |
parents | f89a20e7adc7 |
children |
comparison
equal
deleted
inserted
replaced
355:e77d478e3724 | 356:00060bb8b240 |
---|---|
14 #include "fluid.h" | 14 #include "fluid.h" |
15 #include "trace.h" | 15 #include "trace.h" |
16 | 16 |
17 #include <stdio.h> | 17 #include <stdio.h> |
18 #include <string.h> | 18 #include <string.h> |
19 #include <time.h> | 19 #include <sys/time.h> |
20 | |
21 #if defined(MSC) || defined(BCC) | |
22 #include "windows.h" | |
23 #endif | |
24 | 20 |
25 | 21 |
26 /****************************************************************************** | 22 /****************************************************************************** |
27 * File And Path Name Functions | 23 * File And Path Name Functions |
28 ******************************************************************************/ | 24 ******************************************************************************/ |
211 flowf(NORMAL, " "); | 207 flowf(NORMAL, " "); |
212 break; | 208 break; |
213 } | 209 } |
214 } | 210 } |
215 | 211 |
212 static int get_milliseconds(void) | |
213 { | |
214 struct timeval tv; | |
215 | |
216 gettimeofday(&tv, 0); | |
217 return ((int) tv.tv_sec * 1000) + ((int) tv.tv_usec / 1000); | |
218 } | |
219 | |
216 int stopwatch_start(void) | 220 int stopwatch_start(void) |
217 { | 221 { |
218 #if defined(MSC) || defined(BCC) | 222 return get_milliseconds(); |
219 return GetTickCount(); | |
220 #else | |
221 return 1000 * time(NULL); | |
222 #endif | |
223 } | 223 } |
224 | 224 |
225 int stopwatch_stop(int time_start) | 225 int stopwatch_stop(int time_start) |
226 { | 226 { |
227 #if defined(MSC) || defined(BCC) | 227 return get_milliseconds() - time_start; |
228 return GetTickCount() - time_start; | |
229 #else | |
230 return 1000 * (time(NULL) - time_start); | |
231 #endif | |
232 } | 228 } |
233 | 229 |
234 | 230 |
235 /****************************************************************************** | 231 /****************************************************************************** |
236 * Hexdumping | 232 * Hexdumping |