api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

Sketchup::Drawingelement #visible= execution time

Open bobecka opened this issue 1 year ago • 4 comments

  1. SketchUp Version: 22, 24 (tested)
  2. OS Platform: win 10

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

t1=Time.now
Sketchup.active_model.selection.first.visible=false
t2 = Time.now
p msecs = (t2 - t1) * 1000.0

#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?

bobecka avatar Jun 04 '24 19:06 bobecka

@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...

MSP-Greg avatar Jul 04 '24 02:07 MSP-Greg

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

bobecka avatar Jul 10 '24 20:07 bobecka

Logged as: SKEXT-4246

sketchup[bot] avatar Jul 15 '24 06:07 sketchup[bot]

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.

thomthom avatar Aug 26 '24 14:08 thomthom