Skip to content

Instantly share code, notes, and snippets.

@squiddy
Created March 30, 2011 13:37
Show Gist options
  • Save squiddy/894401 to your computer and use it in GitHub Desktop.
Save squiddy/894401 to your computer and use it in GitHub Desktop.
Benchmark for skylight spreading for bravo
import math
import time
from bravo.chunk import Chunk
from bravo.plugins.generators import simplex, caves
def average(l):
return sum(l) / len(l)
def stddev(l):
return math.sqrt(sum((i - average(l))**2 for i in l))
times = []
for i in range(30):
c = Chunk(0,0)
simplex.populate(c,time.time())
caves.populate(c,int(time.time()))
caves.populate(c,int(time.time()))
caves.populate(c,int(time.time()))
caves.populate(c,int(time.time()))
caves.populate(c,int(time.time()))
caves.populate(c,int(time.time()))
caves.populate(c,int(time.time()))
caves.populate(c,int(time.time()))
b = time.time()
c.regenerate()
times.append((time.time() - b) * 1000)
print average(times), max(times), min(times), stddev(times)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment