Open bobecka opened 4 months ago
@bobecka
Using Time.now
for short operations may yield incorrect results.
I would suggest using Process.clock_gettime(Process::CLOCK_MONOTONIC)
for accurate time interval measurement. It's a lot more characters, but on macOS & Windows it is accurate for sub millisecond measurement. Can't be used with old SU (Ruby) versions.
By 'purging unused entities', do you mean Window -> Model Info -> Statistics -> Purge Unused ?
Regardless, I didn't see the time difference that you saw, time was similar for both operations, around a single mS. Only tested on Windows SU 2024...
By 'purging unused entities', do you mean Window -> Model Info -> Statistics -> Purge Unused ?
yes
before
t1=Process.clock_gettime(Process::CLOCK_MONOTONIC)
Sketchup.active_model.selection.first.visible=false
t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
p msecs = (t2 - t1) * 1000.0
0.7949999999254942
=> 0.7949999999254942
after Purge Unused
t1=Process.clock_gettime(Process::CLOCK_MONOTONIC)
Sketchup.active_model.selection.first.visible=false
t2 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
p msecs = (t2 - t1) * 1000.0
1.5079000004334375
=> 1.5079000004334375
I disable all plugins, SU24. The difference is 2 times slower. Please check with someone else
Logged as: SKEXT-4246
We are not seeing the exact numbers, but they are in the low 1-2ms. However, this is such small item to measure that it's hard to get any realisable values from. Maybe if we measured a larger loop over many entities...
How is it manifesting in your extension. In your example the differences is a few milliseconds, which by itself is not noticeable for en end user experience.
IF do Window->Model Info->Statistics->purging unused entities The procedure Sketchup::Drawingelement #visible= execution time increases several times.
Create a "box" component. Select it, and
my result 0.4378
then return visible and select menu "purging unused entities " try run code again. The result will last several times longer
my result 7.1879
Did it many times and on different versions SU. Is it the same with you?