Skip to content

Instantly share code, notes, and snippets.

View marcelcaraciolo's full-sized avatar
💭
Coding !

Marcel Caraciolo marcelcaraciolo

💭
Coding !
View GitHub Profile
from benchy.api import Benchmark, BenchmarkSuite, BenchmarkRunner
import matplotlib.pyplot as plt
common_setup = """
import numpy
X = numpy.random.uniform(1,5,(1000,))
"""
statement = "cosine_distances(X, X)"
from benchy.api import Benchmark, BenchmarkSuite, BenchmarkRunner
import matplotlib.pyplot as plt
common_setup = """
import numpy
X = numpy.random.uniform(1,5,(1000,))
"""
statement = "cosine_distances(X, X)"
runner = BenchmarkRunner(suite, '.', 'Cosine benchmarks')
n_benchs, results = runner.run()
fig = runner.plot_relative(results, horizontal=True, logy=True)
plt.savefig('%s.png' % runner.name.replace(' ', '_')) # bbox_inches='tight')
runner.plot_absolute(results, horizontal=False, logy=True)
plt.savefig('%s.png' % runner.name.replace(' ', '_')) # bbox_inches='tight')
rst_text = runner.to_rst(results, runner.name.replace(' ', '_') + 'png',
runner = BenchmarkRunner(suite, '.', 'Cosine benchmarks')
n_benchs, results = runner.run()
fig = runner.plot_relative(results, horizontal=True, logy=True)
plt.show()
#plt.savefig('%s_r.png' % runner.name, bbox_inches='tight')
fig = runner.plot_absolute(results, horizontal=False, logy=True)
plt.show()
#plt.savefig('%s.png' % runner.name) # bbox_inches='tight')
runner = BenchmarkRunner(suite, '.', 'Cosine benchmarks')
n_benchs, results = runner.run()
fig = runner.plot_relative(results, horizontal=True, logy=True)
plt.show()
...
runner = BenchmarkRunner(suite, '.', 'Cosine benchmarks')
n_benchs, results = runner.run()
print results
#Output:
'{Benchmark('scipy.spatial 0.8.0'):
{'runtime': {'timing': 18.620705604553223, 'repeat': 3, 'success': True, 'loops': 10, 'timeBaselines': 1994.2583385083014, 'units': 'ms'},
'memory': {'usage': 0.09375, 'units': 'MB', 'repeat': 3, 'success': True}},
from benchy.api import Benchmark, BenchmarkSuite, BenchmarkRunner
import matplotlib.pyplot as plt
...
suite = BenchmarkSuite()
suite.append(benchmark1)
suite.append(benchmark2)
from benchy.api import Benchmark, BenchmarkSuite, BenchmarkRunner
import matplotlib.pyplot as plt
common_setup = """
import numpy
X = numpy.random.uniform(1,5,(1000,))
"""
statement = "cosine_distances(X, X)"
from benchy.api import Benchmark, BenchmarkSuite, BenchmarkRunner
import matplotlib.pyplot as plt
common_setup = """
import numpy
X = numpy.random.uniform(1,5,(1000,))
"""
statement = "cosine_distances(X, X)"
from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup
from time import sleep
BASE_URL = "http://www.cidades.com.br/"
def make_soup(url):
html = urlopen(url).read()
return BeautifulSoup(html)