1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

0029830: STEPCAFControl_Reader poor performance - quadratic dependence

Various performance improvements in STEP read/write algorithms:
- Search for the  label of a shape or component shape is improved using map mechanism instead of brute force iteration.
- Invariant FindEntities() is moved out of the loop in the method getStyledItem in STEPCAFControl/STEPCAFControl_Writer.cxx.
- A pointer to the end of binders chain is added in Transfer_Binder class to speed up adding a binder to the chain.
- Small fixes are added  to eliminate excess copying of handles, calls of handle DownCasts and so on.

Stack overflow is removed during destruction of STEP model with long chains of Transfer_Binder.
It is possible to use the Draw commands ReadStep and WriteStep to read/write from the session without accessing the disk file (use '.' for the file name).

Performance test cases for STEP reading/writing have been added.
This commit is contained in:
msv
2018-06-01 14:38:39 +03:00
committed by bugmaster
parent 0a96e0bbc4
commit 63cdf48ec1
17 changed files with 349 additions and 185 deletions

View File

@@ -1 +1 @@
pload XDE
pload XDE OCAF

2
tests/perf/de/bug29830_1 Normal file
View File

@@ -0,0 +1,2 @@
set use_sharing 1
source "$dirname/$groupname/$gridname/bug29830_dir/script"

2
tests/perf/de/bug29830_2 Normal file
View File

@@ -0,0 +1,2 @@
set use_sharing 0
source "$dirname/$groupname/$gridname/bug29830_dir/script"

24
tests/perf/de/bug29830_3 Normal file
View File

@@ -0,0 +1,24 @@
puts "========"
puts "0029830: Data Exchange, STEPCAFControl_Reader poor performance - quadratic dependence"
puts "========"
puts "Test on stack overflow during destructing the STEP model"
set ncomp 1000
box a 1 1 1
shape co C
for {set i 0} {$i < $ncomp} {incr i} {
tcopy a a1
add a1 co
}
if [info exists D] {Close D}
XNewDoc D
XAddShape D co
puts "Writing STEP model"
WriteStep D .
Close D
puts "Destructing model"
#crash
newmodel

View File

@@ -0,0 +1,105 @@
puts "========"
puts "0029830: Data Exchange, STEPCAFControl_Reader poor performance - quadratic dependence"
puts "========"
puts ""
set copy_cmd tcopy
if $use_sharing {
set copy_cmd copy
}
set dx 2
set dy 4
set dz 6
set nx0 20
set ny 10
set nz 10
if [info exists D] {Close D}
if [info exists D1] {Close D1}
for {set npass 1} {$npass <= 2} {incr npass} {
set nx [expr $nx0 * $npass]
puts "Creating assembly of $nx*$ny*$nz boxes"
plane a 0 0 0 1 0 0
mkface a a 0 3 0 2
shape co C
for {set i 0} {$i < $nx} {incr i} {
for {set j 0} {$j < $ny} {incr j} {
for {set k 0} {$k < $nz} {incr k} {
eval $copy_cmd a a1
ttranslate a1 $dx*$i $dy*$j $dz*$k
add a1 co
}
}
}
XNewDoc D
XAddShape D co
puts "Assigning colors to components"
set i 0
set j 0
set k 0
set shlist [explode co]
set lab [lindex [XFindComponent D co_1] 0]
set taglist [split $lab :]
foreach c $shlist {
set r [expr ($i%3)/3.]
set g [expr ($j%3)/3.]
set b [expr ($k%3)/3.]
set lab [join $taglist :]
XSetColor D $lab $r $g $b
incr k
if {$k%3 == 0} {
incr j
if {$j%3 == 0} {
incr i
}
}
set taglist "[lrange $taglist 0 end-1] [expr [lindex $taglist end] + 1]"
}
puts "Writing STEP model"
chrono cr1 restart
WriteStep D .
chrono cr1 stop
Close D
puts "Reading STEP model"
chrono cr2 restart
ReadStep D1 .
chrono cr2 stop
# check one solid with different locations
XGetOneShape result D1
if $use_sharing {
checknbshapes result -face 1
checknbshapes result -face [expr $nx*$ny*$nz] -t
} else {
checknbshapes result -face [expr $nx*$ny*$nz]
checknbshapes result -face [expr $nx*$ny*$nz] -t
}
if {$npass == 2} {
XShow D1
vfit
vsetdispmode 1
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
}
Close D1
set time_write_$npass [lindex [dchrono cr1 counter "WriteStep_$npass"] end]
set time_read_$npass [lindex [dchrono cr2 counter "ReadStep_$npass"] end]
}
puts "time_write_1=$time_write_1"
puts "time_write_2=$time_write_2"
puts "time_read_1=$time_read_1"
puts "time_read_2=$time_read_2"
set time_raise_write [expr $time_write_2 / $time_write_1]
set time_raise_read [expr $time_read_2 / $time_read_1]
puts "time_raise_write=$time_raise_write"
puts "time_raise_read=$time_raise_read"