aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatthoyts <patthoyts>2005-03-02 12:07:52 +0000
committerpatthoyts <patthoyts>2005-03-02 12:07:52 +0000
commitffc24892ceb6f1a02ca9201efc0074637371a0c0 (patch)
treeedf1082d8d29d806bbc7777aff5ace117d53617f
parent5c69108a616f99f47871c3f96dddfd33b17e58dd (diff)
downloadjimtcl-ffc24892ceb6f1a02ca9201efc0074637371a0c0.zip
jimtcl-ffc24892ceb6f1a02ca9201efc0074637371a0c0.tar.gz
jimtcl-ffc24892ceb6f1a02ca9201efc0074637371a0c0.tar.bz2
Improved the [time] resolution on windows.
-rw-r--r--bench.tcl3
-rw-r--r--jim.c7
2 files changed, 9 insertions, 1 deletions
diff --git a/bench.tcl b/bench.tcl
index 37a905a..edd1bc0 100644
--- a/bench.tcl
+++ b/bench.tcl
@@ -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 ##################################################################
diff --git a/jim.c b/jim.c
index aca713d..35161ba 100644
--- a/jim.c
+++ b/jim.c
@@ -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 */
}
/* -----------------------------------------------------------------------------