From d465d9bc0440d7750e83f0695f56572d38a324d6 Mon Sep 17 00:00:00 2001 From: sebres Date: Fri, 7 Mar 2025 09:58:57 +0000 Subject: cmdMZ.test: improve stability of timerate test for quadratic complexity (increase factor for check), also don't run this test on memory-debug builds (may be very time-consuming) --- tests/cmdMZ.test | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/cmdMZ.test b/tests/cmdMZ.test index 1d6a50b..fcd945c 100644 --- a/tests/cmdMZ.test +++ b/tests/cmdMZ.test @@ -25,6 +25,8 @@ namespace eval ::tcl::test::cmdMZ { namespace import ::tcltest::testConstraint namespace import ::tcltest::test + testConstraint memory [llength [info commands memory]] + if {[namespace which -command ::tcl::unsupported::timerate] ne ""} { namespace import ::tcl::unsupported::timerate } @@ -487,7 +489,9 @@ test cmdMZ-6.12 {Tcl_TimeRateObjCmd: done optimization: nested call of self insi } list [lindex [timerate $m1 1000 5] 2] $x } {5 20} -test cmdMZ-6.13 {Tcl_TimeRateObjCmd: stability by O(n**2), avoid long execution time on growing iteration time} { +test cmdMZ-6.13 {Tcl_TimeRateObjCmd: stability by O(n**2), avoid long execution time on growing iteration time} {!memory} { + # don't run this test on memory-debug builds - it seems to be very time-consuming there, + # what may led to an unexpectedly high increase by such complexity and it'd fail... set result {} # test the function with quadratic complexity (iteration growth 2x, 10x, 100x): foreach e {2 10 100} { @@ -498,10 +502,10 @@ test cmdMZ-6.13 {Tcl_TimeRateObjCmd: stability by O(n**2), avoid long execution }} [set x [expr {$x*$e}]] } 50] lappend result "${e}x" - # check it was too slow (it is OK to use factor 2 to prevent sporadic - # errors on some slow systems or time issues, because if it is not fixed, + # check it was too slow (it is OK to use factor 10 to prevent sporadic + # errors on some slow systems or timing issues, because if it is not fixed, # the execution time may grow hundreds and thousand times): - if {[lindex $m1 6] > 50 * 2} { + if {[lindex $m1 6] > 50 * 10} { lappend result "unexpected long: $m1" } } -- cgit v0.12