How to know how long it takes script to run fully and partially?

How to know how long it takes script to run fully and partially?

I tried this python code but I would like to hear other possible smart alternatives as this returns 0.0 s always to meimage

# Import Time
import time

# Start Run-time
start = time.time()

# Do Something

# Calculate Run-time
time = ("%s s" % (time.time()-start))

### Get run time ###
OUT = time

I saw the new Crumple package that uses 2 package nodes to know how long it takes but is there something like only one python node to feed?

Have you tried/considered using Designscript?
Think i got to the answer to your question when i needed millisecond in my calculated value to make things move, but a bit more flowing, than those 1 second periods. :slight_smile:

All because i wanted to make one of these ones in Revit and see it move…IN Revit :slight_smile:

no idea

1.You start in the normal way in Dynamo, place some nodes, select them, rightclick, and go to Node to Code.
Now you are in the wonderful world of DesignScript :slight_smile:
2.Place d DateTime.Now node and find out what it can do, see it has options?
Now find out what those options are (there lots).
So make a value to feed in the options port with some nodes and do a Node to Code.
There is what you where searching for, if you can translate it into Python

1 Like

The reason i broke my timers in two parts is that there isn’t really a way to track runtime unless you can compare a timber before and after the script runs. Ideally this is done by starting a timer before anything else then comparing the timer at the end by subtracting the times as you found in Crumple.


well, testing the nodes the result is not correct because it only shows the difference in seconds but not the minutes or hours counted as second, for example it says a long process takes 0,029 seconds to run and i was waiting 3 minutes and 0,029 seconds.

on the left, a node of Orchid package, and on the right, a node of Crumple package, Orchid indicates 3 minutes, Crumple indicates 0,003 seconds or something else, not sure how the difference is done here

I modified the crumple python script TimerCheck to get result of seconds correctly, but for me all of that is a pain for a simple thing, I was expecting to get the time run more easy with designscript or OOTB nodes:

from datetime import datetime

# Collect input
datain = IN[0]
start  = IN[1]

# Output the time now
now  =
diff = now - start
secs = divmod(diff.total_seconds(), 60)
OUT = [datain, now, runtimesecs]
1 Like

Yes I could revisit this to add timespans over 1 minute at some point, I seem to recall I didn’t have it measure over that in current state.

Do you know in python how to execute the after a node finishes first to run? with an input

Hi @ruben.romero - have you tried the “TuneUp” extension?

it does not work in my dynamo after install 1.7 version of tune up.


Hrm weird… it should be working in Dynamo 2.6 as it relies on API’s introduced in Dynamo 2.5 :thinking: Are you getting errors in your console about it?

It should be possible to pass an input through a Python IN/OUT before passing it to the next node, which should register the datetime before that node was run. A Python node with just a would run quite quickly so effectively can register the time before a node begins.

1 Like