diff --git a/asv.conf.base.json b/asv.conf.base.json index a5a545a..2b72eb2 100644 --- a/asv.conf.base.json +++ b/asv.conf.base.json @@ -7,7 +7,7 @@ "environment_type": "conda", "matrix": { "req": { - "numpy": ["", null], + "numpy": [""], }, }, "env_dir": ".asv/env", diff --git a/benchmarks/benchmarks.py b/benchmarks/benchmarks.py index 858326f..f8430fa 100644 --- a/benchmarks/benchmarks.py +++ b/benchmarks/benchmarks.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..54a908c --- /dev/null +++ b/pyproject.toml @@ -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"