We have a problem concerning the performance of the SUEntitiesAddGroup function. When we are writing an average sized sketchup file of about 14MB, to which about 1500 groups have been added by this function, then this export takes about 60 seconds and a performance analysis shows that 98% of the time are used by this function.
Also, a large part of the time in this function is used by _towupper_l, a character conversion function.
Is there anything I could do to avoid this problem? In the moment this is our main performance bottleneck.
We did get some reports of Virus Scanners slowing down some of our operations but we never could duplicate it.
This case might be different though. Adding groups require generation of component definitions with unique names and we may have an actual bottleneck there. Is this on a Mac ? Would you happen to have a simple program duplicating it?
Thanks!
This program runs about 20 seconds on my PC and about 88% of the time is spent in SUEntitiesAddGroup
And if I add not only 1000 but 2000 groups, this goes up to 120 seconds and 96%.
I’ve run into this problem as well and it’s a rather bizarre performance quirk. For example, the following Ruby code creates 1000 groups in 25s on my computer
mod = Sketchup.active_model
ent = mod.entities
t0 = Time.now
1.times do
ng = ent.add_group
1000.times do
g = ng.copy
g.entities.add_line [0, 0, 0], [Random::rand * 20 - 10, Random::rand * 20 - 10, Random::rand * 20 - 10]
end
end
t1 = Time.now
puts 'Done '+(t1 - t0).to_s + 's'
However, if you change the loops from 1, 1000 to 32, 32 (~sqrt 1000) the script runs about 10 times faster. The code below creates 1024 groups in 2.4s.
mod = Sketchup.active_model
ent = mod.entities
t0 = Time.now
32.times do
ng = ent.add_group
32.times do
g = ng.copy
g.entities.add_line [0, 0, 0], [Random::rand * 20 - 10, Random::rand * 20 - 10, Random::rand * 20 - 10]
end
end
t1 = Time.now
puts 'Done '+(t1 - t0).to_s + 's'
I don’t know if this is a Ruby only thing but it’s probably worth a try.