diff options
author | sebres <sebres@users.sourceforge.net> | 2019-11-06 23:03:43 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2019-11-06 23:03:43 (GMT) |
commit | 41cd7b2754b0d81fb8fc35f0a3abaace7249471c (patch) | |
tree | 67fc6ed02a4472dca56e2d0dbcd72089c6b7aeaa | |
parent | 4ba2b4fbdf240b54a7d8505ab3f0a75eb4cc2882 (diff) | |
download | tcl-41cd7b2754b0d81fb8fc35f0a3abaace7249471c.zip tcl-41cd7b2754b0d81fb8fc35f0a3abaace7249471c.tar.gz tcl-41cd7b2754b0d81fb8fc35f0a3abaace7249471c.tar.bz2 |
cmdMZ.test: solved timing issues (too slow machines, debug builds, etc)
-rw-r--r-- | tests/cmdMZ.test | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test index 5f94777..f72d39f 100644 --- a/tests/cmdMZ.test +++ b/tests/cmdMZ.test @@ -29,8 +29,6 @@ namespace eval ::tcl::test::cmdMZ { namespace import ::tcl::unsupported::timerate } - testConstraint knownMsvcBug [expr {![info exists ::env(TRAVIS_OS_NAME)] || ![string match windows $::env(TRAVIS_OS_NAME)]}] - # Tcl_PwdObjCmd test cmdMZ-1.1 {Tcl_PwdObjCmd} { @@ -333,8 +331,12 @@ test cmdMZ-4.13 {Tcl_SplitObjCmd: basic split commands} { proc _nrt_sleep {msec} { set usec [expr {$msec * 1000}] set stime [clock microseconds] - while {abs([clock microseconds] - $stime) < $usec} {after 0} + while {abs([clock microseconds] - $stime) < $usec} { + # don't use after 0 unless it's NRT-capable, so yes - busy-wait (but it's more precise): + # after 0 + } } +_nrt_sleep 0; # warm up (clock, compile, etc) test cmdMZ-5.1 {Tcl_TimeObjCmd: basic format of command} { list [catch {time} msg] $msg @@ -351,8 +353,8 @@ test cmdMZ-5.4 {Tcl_TimeObjCmd: nothing happens with negative iteration counts} test cmdMZ-5.5 {Tcl_TimeObjCmd: result format} { regexp {^\d+ microseconds per iteration} [time {format 1}] } 1 -test cmdMZ-5.6 {Tcl_TimeObjCmd: slower commands take longer} knownMsvcBug { - expr {[lindex [time {_nrt_sleep 1}] 0] < [lindex [time {_nrt_sleep 20}] 0]} +test cmdMZ-5.6 {Tcl_TimeObjCmd: slower commands take longer} { + expr {[lindex [time {_nrt_sleep 0.01}] 0] < [lindex [time {_nrt_sleep 10.0}] 0]} } 1 test cmdMZ-5.7 {Tcl_TimeObjCmd: errors generate right trace} { list [catch {time {error foo}} msg] $msg $::errorInfo @@ -404,19 +406,20 @@ test cmdMZ-6.5a {Tcl_TimeRateObjCmd: result format and one iteration} { test cmdMZ-6.5b {Tcl_TimeRateObjCmd: result format without iterations} { regexp {^0 \ws/# 0 # 0 #/sec 0 net-ms$} [timerate {} 0 0] } 1 -test cmdMZ-6.6 {Tcl_TimeRateObjCmd: slower commands take longer, but it remains almost the same time of measument} knownMsvcBug { - set m1 [timerate {_nrt_sleep 0} 20] - set m2 [timerate {_nrt_sleep 0.2} 20] +test cmdMZ-6.6 {Tcl_TimeRateObjCmd: slower commands take longer, but it remains almost the same time of measument} { + lassign [timerate {_nrt_sleep 0} 50] ovh + set m1 [timerate -overhead $ovh {_nrt_sleep 0.01} 50] + set m2 [timerate -overhead $ovh {_nrt_sleep 1.00} 50] list \ [expr {[lindex $m1 0] < [lindex $m2 0]}] \ [expr {[lindex $m1 0] < 100}] \ [expr {[lindex $m2 0] > 100}] \ - [expr {[lindex $m1 2] > 1000}] \ - [expr {[lindex $m2 2] < 1000}] \ - [expr {[lindex $m1 4] > 50000}] \ - [expr {[lindex $m2 4] < 50000}] \ - [expr {[lindex $m1 6] > 10 && [lindex $m1 6] < 100}] \ - [expr {[lindex $m2 6] > 10 && [lindex $m2 6] < 100}] + [expr {[lindex $m1 2] > 500}] \ + [expr {[lindex $m2 2] < 500}] \ + [expr {[lindex $m1 4] > 10000}] \ + [expr {[lindex $m2 4] < 10000}] \ + [expr {[lindex $m1 6] > 5 && [lindex $m1 6] < 100}] \ + [expr {[lindex $m2 6] > 5 && [lindex $m2 6] < 100}] } [lrepeat 9 1] test cmdMZ-6.7 {Tcl_TimeRateObjCmd: errors generate right trace} { list [catch {timerate {error foo} 1} msg] $msg $::errorInfo |