forked from yt-project/yt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Put Kacper's benchmarks into benchmark.py
--HG-- branch : yt
- Loading branch information
1 parent
6d267e4
commit ec58f0f
Showing
2 changed files
with
21 additions
and
57 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,31 @@ | ||
# Write the benchmarking functions here. | ||
# See "Writing benchmarks" in the asv docs for more information. | ||
import numpy as np | ||
from yt import YTArray, YTQuantity | ||
|
||
def time_quantity_init_scalar1(): | ||
3.0 * YTQuantity(1, "m/s") | ||
|
||
class TimeSuite: | ||
""" | ||
An example benchmark that times the performance of various kinds | ||
of iterating over dictionaries in Python. | ||
""" | ||
def setup(self): | ||
self.d = {} | ||
for x in range(500): | ||
self.d[x] = None | ||
|
||
def time_keys(self): | ||
for key in self.d.keys(): | ||
pass | ||
def time_quantity_init_scalar2(): | ||
YTQuantity(3.0, "m/s") | ||
|
||
def time_iterkeys(self): | ||
for key in self.d.iterkeys(): | ||
pass | ||
|
||
def time_range(self): | ||
d = self.d | ||
for key in range(500): | ||
x = d[key] | ||
def time_quantity_init_array(): | ||
np.arange(100000) * YTQuantity(1, "m/s") | ||
|
||
def time_xrange(self): | ||
d = self.d | ||
for key in xrange(500): | ||
x = d[key] | ||
|
||
def time_quantity_init_array2(): | ||
YTArray(np.arange(100000), "m/s") | ||
|
||
class MemSuite: | ||
def mem_list(self): | ||
return [0] * 256 | ||
|
||
def time_quantity_scalar_conversion(): | ||
YTQuantity(3.0, "m/s").in_units("km/hr") | ||
|
||
|
||
def time_quantity_array_conversion(): | ||
YTArray(np.arange(100000), "m/s").in_units("km/hr") | ||
|
||
|
||
def time_quantity_ufunc_sin(): | ||
np.sin(YTArray(np.arange(10000), "degree")) |