https://bugs.kde.org/show_bug.cgi?id=473311

            Bug ID: 473311
           Summary: API Krita.instance().resources("preset") is really
                    slow
    Classification: Applications
           Product: krita
           Version: nightly build (please specify the git hash!)
          Platform: Other
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Scripting
          Assignee: krita-bugs-n...@kde.org
          Reporter: grum...@grum.fr
  Target Milestone: ---

SUMMARY
When using method Krita.instance().resources("preset") for the first time in a
Krita session, execution is pretty slow.

STEPS TO REPRODUCE
--> Ensure no plugin is active 

1. Open Scripter
2. Execute following script 
```
import time

ts=time.time()
l = Krita.instance().resources("preset")
print(len(l), time.time() - ts)
```


OBSERVED RESULT
I have 1058 presets on my DEV computer
-> First execution duration is ~3.932s
-> Next execution duration are ~0.019s

EXPECTED RESULT
For users with a lot of presets (I'm pretty sure to not be the only one :-)) a
plugin that call this method will freeze Krita for a 'long' duration (on my
side, at plugin startup)

Not sure why there's a such difference between first execution and next one,
and if it's really possible or not to fix it.
I suppose the instantiation of 1058 Resources objects is the reason; if yes, in
this case, a solution could be:
- implement Krita.instance().resourceNames("preset")
  ==> return only an array of String of resources names 
- implement Krita.instance().resource("preset", "resourcename")
  ==> return only one Resource object 

SOFTWARE/OS VERSIONS
Krita
 Version: 5.2.0-beta1 (git 0447d30)

Qt
  Version (compiled): 5.15.7
  Version (loaded): 5.15.7

OS Information
  Build ABI: x86_64-little_endian-lp64
  Build CPU: x86_64
  CPU: x86_64
  Kernel Type: linux
  Kernel Version: 5.19.0-45-generic
  Pretty Productname: KDE neon 5.27
  Product Type: neon
  Product Version: 22.04
  Desktop: KDE
  Appimage build: Yes

Hardware Information
  GPU Acceleration: auto
  Memory: 64201 Mb
  Number of Cores: 24
  Swap Location: /tmp
  Built for: sse2
  Base instruction set: fma3+avx2
  Supported instruction sets: fma3+avx2 avx2 fma3+avx avx fma4 fma3+sse4.2
sse4.2 sse4.1 ssse3 sse3 sse2 

REMARK
Problem is not relative to 5.2, it also occurs on
- 5.1.5 
- 5.3 
- 5.0.2 (even if it was faster, ~2.75s to load resources)

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to