Skip to content

Instantly share code, notes, and snippets.

@notionparallax
Created July 21, 2014 05:50
Show Gist options
  • Save notionparallax/003f97c58ac2c018c072 to your computer and use it in GitHub Desktop.
Save notionparallax/003f97c58ac2c018c072 to your computer and use it in GitHub Desktop.
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
#from clr import AddReference as addr
#addr("Grasshopper")
#from System import Object
#from Grasshopper import DataTree
#from Grasshopper.Kernel.Data import GH_Path
import random
import math
from datetime import datetime
import ghpythonlib.components as ghcomp
import ghpythonlib.parallel
cloudSize = len(pointCloud)
#Rhinoscript
startTime = datetime.now()
for i in range(iterations):
p1 = pointCloud[random.randint(0,cloudSize-1)]
p2 = pointCloud[random.randint(0,cloudSize-1)]
throwawayVariable = rs.Distance(p1,p2)
endTime = datetime.now()
Rhinoscript = endTime - startTime
#Grasshopper
startTime = datetime.now()
for i in range(iterations):
p1 = pointCloud[random.randint(0,cloudSize-1)]
p2 = pointCloud[random.randint(0,cloudSize-1)]
throwawayVariable = ghcomp.Distance(p1,p2)
endTime = datetime.now()
Grasshopper = endTime - startTime
#GHparallel
startTime = datetime.now()
p1 = []
p2 = []
for i in range(iterations):
p1.append(pointCloud[random.randint(0,cloudSize-1)])
p2.append(pointCloud[random.randint(0,cloudSize-1)])
pairs = zip(p1,p2)
throwawayVariable = ghpythonlib.parallel.run(ghcomp.Distance, pairs, True)
endTime = datetime.now()
GHparallel = endTime - startTime
p1 = None
p2 = None
#native
startTime = datetime.now()
for i in range(iterations):
p1 = pointCloud[random.randint(0,cloudSize-1)]
p2 = pointCloud[random.randint(0,cloudSize-1)]
throwawayVariable = math.sqrt( math.pow(p1.X-p2.X, 2) + math.pow(p1.Y-p2.Y, 2) + math.pow(p1.Z-p2.Z, 2))
endTime = datetime.now()
native = endTime - startTime
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment