1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-01 17:36:21 +03:00
occt/tests/bugs/caf/bug31918_1
2025-03-07 15:34:32 +00:00

101 lines
3.4 KiB
Plaintext

puts "==========="
puts "0031918: Application Framework - New binary format for fast reading part of OCAF document"
puts "==========="
set docname ${imagedir}/doc_${casename}.cbfl
NewDocument D0 BinLOcaf
UndoLimit D0 10
NewCommand D0
# set an array 1000 values from 100 to 1099
set values "100 "
for {set i 101} {$i < 1100} {incr i} {set values "$values $i"}
# set 100 arrays to sub-labels of 0:1 0:2 0:3 and 0:4
for {set lab 1} {$lab <= 4} {incr lab} {
for {set sublab 1} {$sublab <= 100} {incr sublab} {
set command "SetIntArray D0 0:$lab:$sublab 0 1 1000 $values"
eval $command
SetReal D0 0:$lab:$sublab 0.1
}
}
CommitCommand D0
SaveAs D0 ${docname}
Close D0
# 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 quarter_time [action_time -read0:2]
puts "Quarter of document open time $quarter_time mcs"
# Check that open of quarter of the document is significantly faster than open of whole.
if { [expr $quarter_time * 1.5] > $whole_time } {
puts "Error : loading of quarter of the document content too slow relatively to the whole document load"
}
set four_quarters_time [action_time -read0:1 -read0:2 -read0:3 -read0:4]
puts "Four quarters of document open time $four_quarters_time mcs"
# Check that open of four quarters of the document is not too much slower than opening of the whole document.
if { [expr $four_quarters_time * 0.9] > $whole_time } {
puts "Error : loading of four quarters of the document content too slow relatively to the whole document load"
}
set no_arrays_time [lindex [time {
Open ${docname} D4 -skipTDataStd_IntegerArray -read0:2
}] 0]
puts "Quarter of document without arrays open time $no_arrays_time mcs"
set attrs [Attributes D4 0:2:13]
if {"${attrs}" != "TDataStd_Real "} {
puts "Error : loading of document skipping arrays contains invalid attributes list '${attrs}'"
}
if {![catch {Attributes D4 0:1:1:13}] || ![catch {Attributes D4 0:1:3:14}] || ![catch {Attributes D4 0:1:4:1}]} {
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]
puts "Half of document arrays open time $append_arrays_time mcs"
set attrs [Attributes D4 0:2:13]
if {"${attrs}" != "TDataStd_Real TDataStd_IntegerArray "} {
puts "Error : loading of document reading arrays separately contains invalid attributes list '${attrs}'"
}
set attrs [Attributes D4 0:3:1]
if {"${attrs}" != "TDataStd_IntegerArray "} {
puts "Error : loading of document reading arrays separately contains invalid attributes list on subtree 3 '${attrs}'"
}
if {![catch {Attributes D4 0:1:1:13}] || ![catch {Attributes D4 0:1:4:1}]} {
puts "Error : loading of document reading arrays separately contains invalid attributes list on 1 and 4 subtrees"
}
Close D4