-
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.
ENH: Add an example of parametrization
- Loading branch information
Showing
3 changed files
with
57 additions
and
15 deletions.
There are no files selected for viewing
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
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,18 +1,38 @@ | ||
from asv_samples.benchme import add_arr | ||
import numpy as np | ||
from asv_runner.benchmarks.mark import parameterize, SkipNotImplemented | ||
from asv_samples.benchme import NUMPY_AVAILABLE | ||
|
||
if not NUMPY_AVAILABLE: | ||
raise SkipNotImplemented("Can't run without NumPy") | ||
|
||
class TimeSuite: | ||
""" | ||
Benchmark that times various operations, including custom summation of | ||
lists. | ||
""" | ||
@parameterize({"n":[10, 100]}) | ||
def time_sort(n): | ||
np.sort(np.random.rand(n)) | ||
|
||
def setup(self): | ||
self.list1 = [i for i in range(500)] | ||
self.list2 = [i for i in range(500, 1000)] | ||
@parameterize({'n': [10, 100], 'func_name': ['range', 'arange']}) | ||
def time_ranges_multi(n, func_name): | ||
f = {'range': range, 'arange': np.arange}[func_name] | ||
for i in f(n): | ||
pass | ||
|
||
def time_add_arr(self): | ||
""" | ||
Time the add_arr function with two lists of numbers. | ||
""" | ||
add_arr(self.list1, self.list2) | ||
@parameterize({"size": [10, 100, 200]}) | ||
class TimeSuiteDecoratorSingle: | ||
def setup(self, size): | ||
self.d = {} | ||
for x in range(size): | ||
self.d[x] = None | ||
|
||
def time_keys(self, size): | ||
for key in self.d.keys(): | ||
pass | ||
|
||
def time_values(self, size): | ||
for value in self.d.values(): | ||
pass | ||
|
||
@parameterize({'n': [10, 100], 'func_name': ['range', 'arange']}) | ||
class TimeSuiteMultiDecorator: | ||
def time_ranges(self, n, func_name): | ||
f = {'range': range, 'arange': np.arange}[func_name] | ||
for i in f(n): | ||
pass |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[build-system] | ||
build-backend = "hatchling.build" | ||
requires = [ "hatch-vcs", "hatchling" ] | ||
|
||
[tool.hatch.build.hooks.vcs] | ||
version-file = "_version.py" | ||
|
||
[tool.hatch.build] | ||
include = [ "asv_samples/**/*.py", "asv_samples/*.py" ] | ||
|
||
[project] | ||
name = "asv_samples" | ||
version = "0.1.0" | ||
description = "A set of asv samples" | ||
authors = [ | ||
{name = "Rohit Goswami", email = "rgoswami@ieee.org"}, | ||
] | ||
license = {file = "LICENSE"} | ||
readme = "readme.md" | ||
|
||
[project.urls] | ||
repository = "https://github.com/HaoZeke/asv_samples" |