Graph Runtimes for Various Methods



Once every few months someone asks “Which is faster, nodes, code blocks or python?” and the answer is along the lines of “It depends, but generally Python>Code Blocks>Nodes for speed.”

I was curious to know how much of a difference I got between the various methods on a dataset which actually had some teeth to it. So I did some brainstorming, and asked myself “What can I easily do with all methods which will push my system enough to get a real result, but be fast enough to allow for analysis?” The answer: List Permutations. A list 8 items deep has 322,560 permutations. Enough to make my system work, but not enough cause significant boredom while I waited.

Using Dynamo sandbox (not attached to Revit), I created 4 different graphs which would produce the permutations, one with nodes, one with “node to code”, one with a simplified code block, and one with a python script (I’m not a python guru - code was copied from Here).

I then stuck a custom node for “time finished” on the end of the result, subtracted that from the result of a DateTime.Now node, got the time span in total seconds, and then used a python node to produce an informing popup on the time to complete. I then manually entered the result into excel. I thought about appending the result to a CSV or xls file, but that meant that I’d have to read results and deal with data times as I went, which would put data in the ram which could skew the results.

Interestingly, no time came up the same for any node, and the times varied a lot more than I expected. After 5 runs I closed dynamo and did one run with each on a “clean” open, and then 4 more runs to give myself an even 10 results.

I may run this again sometime with a larger list (9 deep? 10 crashed my system for the weekend for a single run last winter), through dynamo player (faster?), or for different calculations (geometry intersections).

My Findings:

Average Speed:

  1. Python - 3.19
  2. Basic Code Block - 3.23
  3. Simplified CB - 3.23
  4. Nodes - 3.40

Median Speed:

  1. Python - 3.20
  2. Simplified CB - 3.22
  3. Basic Code Block- 3.23
  4. Nodes - 3.24

Fasted run:

  1. Basic Code Block - 2.92
  2. Nodes - 3.01
  3. Python - 3.02
  4. Simplified CB - 3.13

Slowest Run:

  1. Python - 3.34
  2. SImplified Code - 3.38
  3. Basic Code Block - 3.59
  4. Nodes - 4.78

Deviation in Runs:

  1. Simplified CB - 0.25
  2. Python - 0.33
  3. Basic Code Block - 0.67
  4. Nodes - 1.77

Overall Speed Ranking (sum of rankings for each metric, sorted low to high)

  1. Python - 8
  2. Basic Code Block - 12
  3. Simplified Code Block - 12
  4. Nodes - 18

All data in XLS file, DYF for time report, and DYNs for anyone who’s interested or would like to test for them self. Please let me know if you do test and find something different, or if you see an issue with my method (ie: that python could have been WAY more efficient).


Custom node to report time when input arrives: Time Finished.dyf (2.7 KB)
Using Nodes: Nodes.dyn (9.9 KB)
Using Basic Code Block: Basic Code Block.dyn (6.9 KB)
Using Simplified Code Block: Simplified Code Block.dyn (6.8 KB)
Using Python: Python.dyn (7.2 KB)
Results in Excel: Times.xlsx (9.5 KB)