diff options
author | patthoyts <patthoyts> | 2005-03-02 12:07:52 +0000 |
---|---|---|
committer | patthoyts <patthoyts> | 2005-03-02 12:07:52 +0000 |
commit | ffc24892ceb6f1a02ca9201efc0074637371a0c0 (patch) | |
tree | edf1082d8d29d806bbc7777aff5ace117d53617f | |
parent | 5c69108a616f99f47871c3f96dddfd33b17e58dd (diff) | |
download | jimtcl-ffc24892ceb6f1a02ca9201efc0074637371a0c0.zip jimtcl-ffc24892ceb6f1a02ca9201efc0074637371a0c0.tar.gz jimtcl-ffc24892ceb6f1a02ca9201efc0074637371a0c0.tar.bz2 |
Improved the [time] resolution on windows.
-rw-r--r-- | bench.tcl | 3 | ||||
-rw-r--r-- | jim.c | 7 |
2 files changed, 9 insertions, 1 deletions
@@ -2,7 +2,8 @@ proc bench {title script} { while {[string length $title] < 20} { append title " " } - puts "$title - [time $script]" + catch {time $script} res + puts "$title - $res" } ### BUSY LOOP ################################################################## @@ -457,9 +457,16 @@ char *Jim_StrDupLen(char *s, int l) /* Returns microseconds of CPU used since start. */ static long JimClock(void) { +#ifdef WIN32 + LARGE_INTEGER t, f; + QueryPerformanceFrequency(&f); + QueryPerformanceCounter(&t); + return (long)((t.QuadPart * 1000000) / f.QuadPart); +#else /* ! WIN32 */ clock_t clocks = clock(); return (long)(clocks*(1000000/CLOCKS_PER_SEC)); +#endif /* WIN32 */ } /* ----------------------------------------------------------------------------- |