]> OCCT Git - occt.git/commitdiff
0032870: Tests - bugs/caf/bug31918_1 is unstable
authormpv <mpv@opencascade.com>
Mon, 14 Mar 2022 15:03:59 +0000 (18:03 +0300)
committersmoskvin <smoskvin@opencascade.com>
Mon, 14 Mar 2022 16:25:14 +0000 (19:25 +0300)
Improved the test stability: created 10 iterations of measurements and take the minimum to
minimize the affect of other processes and threads; increased the compare range of
the quarter and the whole of the document load.

tests/bugs/caf/bug31918_1

index 35e358f76654946169fb470cac57580ea93de795..131529f2fe2588516f23a9838aea3a55fc557d6a 100644 (file)
@@ -27,27 +27,37 @@ CommitCommand D0
 SaveAs D0 ${docname}
 Close D0
 
-set whole_time [lindex [time {
-  Open ${docname} D1
-  Close D1
-} 20] 0]
+# Computes the elapsed time of open and close document with a given arguments (as text).
+# It launches 10 iteration, 10 actions in each. Returns time of average time of the minimum-time iteration.
+proc action_time args {
+  global docname
+  set min_time 1000000
+  for {set iter 0} {$iter < 10} {incr iter} {
+    set iter_time [lindex [time {
+      Open ${docname} D {*}$args
+      Close D
+    } 10] 0]
+    puts "Iteration time $iter_time mcs"
+    if {$iter_time < $min_time} {
+      set min_time $iter_time
+    }
+  }
+
+  return $min_time
+}
+
+set whole_time [action_time]
 puts "Whole document open time $whole_time mcs"
 
-set quater_time [lindex [time {
-  Open ${docname} D2 -read0:2
-  Close D2
-} 20] 0]
+set quater_time [action_time -read0:2]
 puts "Quater of document open time $quater_time mcs"
 
-# Check that open of quater of the document is at least twice faster than open of whole.
-if { [expr $quater_time * 2] > $whole_time } {
+# Check that open of quater of the document is significantly faster than open of whole.
+if { [expr $quater_time * 1.75] > $whole_time } {
   puts "Error : loading of quater of the document content too slow relatively to the whole document load"
 }
 
-set four_quaters_time [lindex [time {
-  Open ${docname} D3 -read0:1 -read0:2 -read0:3 -read0:4
-  Close D3
-} 20] 0]
+set four_quaters_time [action_time -read0:1 -read0:2 -read0:3 -read0:4]
 puts "Four quaters of document open time $four_quaters_time mcs"
 
 # Check that open of four quaters of the document is not too much slower than opening of the whole document.
@@ -69,6 +79,7 @@ if {![catch {Attributes D4 0:1:1:13}] || ![catch {Attributes D4 0:1:3:14}] || ![
   puts "Error : loading of document skipping arrays and sub-trees contains invalid attributes list"
 }
 
+# check for appending arrays to the document from the file
 set append_arrays_time [lindex [time {
   Open ${docname} D4 -append -readTDataStd_IntegerArray -read0:2 -read0:3
 }] 0]