SketchUp / api-issue-tracker

Public issue tracker for the SketchUp and LayOut's APIs
https://developer.sketchup.com/
39 stars 10 forks source link

Sketchup::Drawingelement #visible= execution time #981

Open bobecka opened 4 months ago

bobecka commented 4 months ago
  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?

MSP-Greg commented 3 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...

bobecka commented 2 months ago

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

sketchup[bot] commented 2 months ago

Logged as: SKEXT-4246

thomthom commented 1 month ago

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.