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
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)" | |
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
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)" | |
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
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', |
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
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') |
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
runner = BenchmarkRunner(suite, '.', 'Cosine benchmarks') | |
n_benchs, results = runner.run() | |
fig = runner.plot_relative(results, horizontal=True, logy=True) | |
plt.show() |
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
... | |
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}}, |
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
from benchy.api import Benchmark, BenchmarkSuite, BenchmarkRunner | |
import matplotlib.pyplot as plt | |
... | |
suite = BenchmarkSuite() | |
suite.append(benchmark1) | |
suite.append(benchmark2) |
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
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)" | |
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
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)" | |
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
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) |