Page 2 of 2

Re: Time stamps for time since last activated

PostPosted: Wed Jul 24, 2013 6:34 pm
by matt (support)
Dewster35 wrote:
Do apple scripts not run in their own process? I usually try to run them not embedded whenever I am running any sort of script.

• Linked AppleScripts run in their own process which is a bit slower to start because the new process has to be loaded and executed.
• Linked Python scripts run in their own process which is also slower to start.
• Embedded AppleScripts run in the main Indigo Server thread and can block the server if they hang up or have delays. Not recommended except for very simple scripts that only target the Indigo Server (not other apps).
• Embedded Python scripts run in a separate process (from Indigo Server) but they all share the same process. Startup time is only slower for the first script that is executed, then the rest are very fast because the process is already running. As long as a script doesn't take more than 10 seconds to executed, embedded is recommend for python.

Re: Time stamps for time since last activated

PostPosted: Wed Jul 24, 2013 7:03 pm
by Dewster35
Is there a way to find out how long a script is taking to be executed in python?

Re: Time stamps for time since last activated

PostPosted: Sun Jul 28, 2013 2:03 pm
by rhanson
Via brute force is simple enough. That is, record the time at the top and bottom of your script.

Code: Select all
# at beginning
startTime = datetime.now()

...

# at bottom of script
endTime = datetime.now()
delta = endTime - startTime
indigo.server.log("Elapsed time: " + str(delta))


... or use the formatting you've already figured out :-)

Re: Time stamps for time since last activated

PostPosted: Thu Aug 12, 2021 1:20 pm
by Bildhauer
Maybe someone can help me here:

    1. Whats the best way to save a timestamp to variable?
    2. I want to compare a stored timestamp with a new one and need the difference in days. How can I manage it?

´Thanks in advance!

Bildhauer1963