Skip to content

Commit f007c97

Browse files
authored
Merge pull request #29 from numpy/asv-improvements
Asv improvements
2 parents e808a0f + da09ad8 commit f007c97

File tree

6 files changed

+58
-61
lines changed

6 files changed

+58
-61
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,4 @@ dmypy.json
132132
compile_commands.json
133133

134134
.ruff-cache/
135+
.asv
File renamed without changes.

benchmarks/asv.conf.json renamed to asv_benchmarks/asv.conf.json

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,18 @@
1616
// The Python project's subdirectory in your repo. If missing or
1717
// the empty string, the project is assumed to be located at the root
1818
// of the repository.
19-
"repo_subdir": "",
19+
// "repo_subdir": "",
2020

2121
// Customizable commands for building, installing, and
2222
// uninstalling the project. See asv.conf.json documentation.
2323
//
2424
"install_command": [
2525
"pip install -i https://pypi.anaconda.org/scipy-wheels-nightly/simple numpy",
2626
"pip install meson-python patchelf wheel",
27-
"in-dir={conf_dir} pip install ./asciidtype/ --no-build-isolation",
28-
"in-dir={conf_dir} pip install ./strptrdtype/ --no-build-isolation"
27+
"in-dir={conf_dir} pip install ../asciidtype/ --no-build-isolation",
28+
"in-dir={conf_dir} pip install ../stringdtype/ --no-build-isolation"
2929
],
30-
"uninstall_command": ["return-code=any pip uninstall -y asciidtype strptrdtype"],
30+
"uninstall_command": ["return-code=any pip uninstall -y asciidtype stringdtype"],
3131
"build_command": [
3232
"pip -V"
3333
/* "python setup.py build", */
@@ -56,7 +56,7 @@
5656
//"install_timeout": 600,
5757

5858
// the base URL to show a commit for the project.
59-
// "show_commit_url": "http://github.com/owner/project/commit/",
59+
"show_commit_url": "http://github.com/numpy/numpy-user-dtypes/commit/",
6060

6161
// The Pythons you'd like to test against. If not provided, defaults
6262
// to the current version of Python used to run `asv`.
@@ -82,15 +82,9 @@
8282
// new environments. A value of ``null`` means that the variable
8383
// will not be set for the current combination.
8484
//
85-
// "matrix": {
86-
// "req": {
87-
// "numpy": ["1.6", "1.7"],
88-
// "six": ["", null], // test with and without six installed
89-
// "pip+emcee": [""] // emcee is only available for install with pip.
90-
// },
91-
// "env": {"ENV_VAR_1": ["val1", "val2"]},
92-
// "env_nobuild": {"ENV_VAR_2": ["val3", null]},
93-
// },
85+
"matrix": {
86+
"env_nobuild": {"NUMPY_EXPERIMENTAL_DTYPE_API": "1"},
87+
},
9488

9589
// Combinations of libraries/python versions can be excluded/included
9690
// from the set to test. Each entry is a dictionary containing additional
File renamed without changes.

asv_benchmarks/benchmarks/strings.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Write the benchmarking functions here.
2+
# See "Writing benchmarks" in the asv docs for more information.
3+
import uuid
4+
5+
import numpy as np
6+
7+
from asciidtype import ASCIIDType
8+
from stringdtype import StringDType
9+
10+
11+
def generate_data(n=100000):
12+
"""Generate data for the benchmarks.
13+
14+
The vast majority of the time spent benchmarking is generating data; generate it
15+
once and store it to avoid having to do this every run.
16+
"""
17+
strings_list = [str(uuid.uuid4()) + "\n" for i in range(n)]
18+
19+
with open("strings", "w") as f:
20+
f.writelines(strings_list)
21+
22+
23+
class TimeASCIIDType:
24+
def setup(self):
25+
self.ascii_dtype_object = ASCIIDType(36)
26+
with open("strings", "r") as f:
27+
self.strings = f.readlines()
28+
29+
def time_allocate(self):
30+
_ = np.array(self.strings, dtype=self.ascii_dtype_object)
31+
32+
33+
class TimeStringDType:
34+
def setup(self):
35+
self.string_dtype_object = StringDType()
36+
with open("strings", "r") as f:
37+
self.strings = f.readlines()
38+
39+
def time_allocate(self):
40+
_ = np.array(self.strings, dtype=self.string_dtype_object)
41+
42+
43+
class TimeObjectDType:
44+
def setup(self):
45+
with open("strings", "r") as f:
46+
self.strings = f.readlines()
47+
48+
def time_allocate(self):
49+
_ = np.array(self.strings, dtype=object)

benchmarks/benchmarks.py

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)