Last active
August 29, 2015 14:06
-
-
Save zeffii/5eed246e5851ed7b18ad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cProfile | |
setup = """\ | |
from mathutils import Vector | |
from random import random | |
from itertools import zip_longest | |
from data_structure import fullList | |
""" | |
function_declaration1 = """\ | |
def make_line_original(integer, step): | |
vertices = [(0.0, 0.0, 0.0)] | |
integer = [int(integer) if type(integer) is not list else int(integer[0])] | |
if type(step) is not list: | |
step = [step] | |
fullList(step, integer[0]) | |
for i in range(integer[0]-1): | |
v = Vector(vertices[i]) + Vector((step[i], 0.0, 0.0)) | |
vertices.append(v[:]) | |
edges = [] | |
for i in range(integer[0]-1): | |
edges.append((i, i+1)) | |
return vertices, edges | |
""" | |
function_declaration2 = """\ | |
def make_line_mod1(integer, step): | |
integer = [int(integer) if type(integer) is not list else int(integer[0])] | |
vertices = [(0,0,0)] | |
vadd = vertices.append | |
if type(step) is not list: | |
step = [step] | |
fullList(step, integer[0]) | |
component = 0.0 | |
for i in range(1, integer[0]): | |
component += step[i] | |
v = (component, 0.0, 0.0) | |
vadd(v) | |
edges = [] | |
for i in range(integer[0]-1): | |
edges.append((i, i+1)) | |
return vertices, edges | |
""" | |
def test(): | |
command1 = """m = [make_line_original(200, 0.2) for m in range(200)]""" | |
cProfile.run(setup + function_declaration1 + command1) | |
command2 = """m = [make_line_mod1(200, 0.2) for m in range(200)]""" | |
cProfile.run(setup + function_declaration2 + command2) | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment