Can we preload java libraries for sikuli

Asked by Avinash

In every run it loads libraries:

runIDE.cmd -r Hello.sikuli

If multiple scripts are to be run ,it consumes lot of time.(Which is not the actual script execution time)

Is it possible to preload those libraries, so that time taken is actual script execution time and not library loading time plus script execution time.

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

It is not the loading of the libraries, but the startup of the scripting support and the internal preparation to run the script, that takes between 3 and 5 seconds and cannot be reduced by any means for a single script run.

The only possibility is to schedule the run of the next script from within a main script like this:

# content main script
# supposing all .sikuli in the same folder as main.sikuli
import script1
import script2
import script3

This works, since at import all code at indent level 0 is executed once at import time.

When importing a .sikuli, the image path is set automatically, so that the images are found.
This works without problems as long as the image filenames in the different scripts are different.

If they are not, come back.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

BTW: in version 1.1.0 the -r parameter will support more than one script name to be run in a row (not yet implemented though)

Revision history for this message
Avinash (avinash-jha) said :
#3

Hi RaiMan,

I was reading about running 2 scripts simultaneously.If one script is
already running(ie. all libraries are loaded,related to opencv[.so in
linux and .dll in windows]) ,why the other script again loads all
libraries.Can't it use the same loaded .so's.Could you also give a
brief idea of the source code section in which this loading of
libraries is done, so that I can investigate further.It would be great
help.Thanks.

Best Regards,
Avinash Jha

On Mon, Aug 25, 2014 at 1:42 PM, RaiMan
<email address hidden> wrote:
> Your question #253560 on Sikuli changed:
> https://answers.launchpad.net/sikuli/+question/253560
>
> Linked to bug: #1361094
> https://bugs.launchpad.net/bugs/1361094
> "[request] want to run more than one script in a row from command line"
>
> --
> You received this question notification because you asked the question.

Revision history for this message
RaiMan (raimund-hocke) said :
#4

--- as long as the scripts are run in the same JVM, the stuff is only loaded once

Running scripts in parallel in different JVMs will lead to startup processing in each JVM.
But running scripts in parallel in different JVMs does not make any sense, since Sikuli currently has no means to coordinate mouse and keyboard usage in these situations.

Up to version 1.0.1 the Sikuli stuff is in no aspects thread safe and does not coordinate mouse/keyboard between threads/processes at all.

Beginning with version 1.1.0 mouse and keyboard usage can be coordinated between threads/and processes and it will be possible to run scripts in parallel in the same JVM (ScriptRunner.runScript()). But this is not yet available/fully tested.

If you want to do anything of value in this area, then you might look into the sources on github (start at sikulix.com).
the native stuff is loaded in org.sikuli.basics.ResourceLoader.

But as already mentioned: The library loading is not taking the time, it is the startup of the Jython script runner, that takes the time. It is on the list, to check the possibility of caching in this area.

… and if you just use the solution mentioned in comment #1, you only have the startup time once.

Can you help with this problem?

Provide an answer of your own, or ask Avinash for more information if necessary.

To post a message you must log in.