Add in benchmarks.
This commit is contained in:
parent
2b929b983a
commit
4659cc53ff
5
Pipfile
5
Pipfile
|
@ -3,12 +3,11 @@ name = "pypi"
|
||||||
url = "https://pypi.org/simple"
|
url = "https://pypi.org/simple"
|
||||||
verify_ssl = true
|
verify_ssl = true
|
||||||
|
|
||||||
[dev-packages]
|
|
||||||
maturin = "*"
|
|
||||||
|
|
||||||
[packages]
|
[packages]
|
||||||
pyo3-pack = "*"
|
pyo3-pack = "*"
|
||||||
pytest = "*"
|
pytest = "*"
|
||||||
|
pytest-benchmark = "*"
|
||||||
|
maturin = "*"
|
||||||
|
|
||||||
[requires]
|
[requires]
|
||||||
python_version = "3.6"
|
python_version = "3.6"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "f446b2fd462f856414a21e7626c27a9736f94dca7ec455bfc5c575699f366703"
|
"sha256": "6abbd7128fe33662a80c04ff5d016c068652998013bb51d519098f30f7b5f182"
|
||||||
},
|
},
|
||||||
"pipfile-spec": 6,
|
"pipfile-spec": 6,
|
||||||
"requires": {
|
"requires": {
|
||||||
|
@ -38,6 +38,18 @@
|
||||||
"markers": "python_version < '3.8'",
|
"markers": "python_version < '3.8'",
|
||||||
"version": "==0.23"
|
"version": "==0.23"
|
||||||
},
|
},
|
||||||
|
"maturin": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:0e58532b845aad5d1a1df9dd6ef56456d63b737e4a3a30e8572447fbc23d151f",
|
||||||
|
"sha256:4e2f73f97d2f030da42a2758e56e95ce2491afd9a080e70b78b088128145af87",
|
||||||
|
"sha256:90efda63af6c565a986d1e050673e033cbefc3c9b2996fa2fdf9e6d94d5bd179",
|
||||||
|
"sha256:9eecde82ee37772764d6237b7784912241d0b93292f72ff29a921f33842691ca",
|
||||||
|
"sha256:a435b280afcba7a1ca7203a60b198d8f93d874db0ffed13ee537c5066160b429",
|
||||||
|
"sha256:ab75ad31257d2238673bde7d402c2e7608e37a8042350ca7fd51f70382a1a638"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==0.7.6"
|
||||||
|
},
|
||||||
"more-itertools": {
|
"more-itertools": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832",
|
"sha256:409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832",
|
||||||
|
@ -66,6 +78,12 @@
|
||||||
],
|
],
|
||||||
"version": "==1.8.0"
|
"version": "==1.8.0"
|
||||||
},
|
},
|
||||||
|
"py-cpuinfo": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:2cf6426f776625b21d1db8397d3297ef7acfa59018f02a8779123f3190f18500"
|
||||||
|
],
|
||||||
|
"version": "==5.0.0"
|
||||||
|
},
|
||||||
"pyo3-pack": {
|
"pyo3-pack": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:3b9b34ba43ad009c3b4ad3f508d0d364891f47242f47a604b4e5ea68dfcab32d",
|
"sha256:3b9b34ba43ad009c3b4ad3f508d0d364891f47242f47a604b4e5ea68dfcab32d",
|
||||||
|
@ -92,6 +110,14 @@
|
||||||
"index": "pypi",
|
"index": "pypi",
|
||||||
"version": "==5.2.2"
|
"version": "==5.2.2"
|
||||||
},
|
},
|
||||||
|
"pytest-benchmark": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:4512c6805318d07926efcb3b39f7b98a10d035305a93edfd5329c86cbf9cfbf7",
|
||||||
|
"sha256:ab851115ce022639173b9497d4a4183a1d8fe9cdcf8fab9d8a57607008aedd3d"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"version": "==3.2.2"
|
||||||
|
},
|
||||||
"six": {
|
"six": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
|
"sha256:3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c",
|
||||||
|
@ -99,6 +125,13 @@
|
||||||
],
|
],
|
||||||
"version": "==1.12.0"
|
"version": "==1.12.0"
|
||||||
},
|
},
|
||||||
|
"toml": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c",
|
||||||
|
"sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e"
|
||||||
|
],
|
||||||
|
"version": "==0.10.0"
|
||||||
|
},
|
||||||
"wcwidth": {
|
"wcwidth": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
|
"sha256:3df37372226d6e63e1b1e1eda15c594bca98a22d33a23832a90998faa96bc65e",
|
||||||
|
@ -114,25 +147,5 @@
|
||||||
"version": "==0.6.0"
|
"version": "==0.6.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"develop": {
|
"develop": {}
|
||||||
"maturin": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:0e58532b845aad5d1a1df9dd6ef56456d63b737e4a3a30e8572447fbc23d151f",
|
|
||||||
"sha256:4e2f73f97d2f030da42a2758e56e95ce2491afd9a080e70b78b088128145af87",
|
|
||||||
"sha256:90efda63af6c565a986d1e050673e033cbefc3c9b2996fa2fdf9e6d94d5bd179",
|
|
||||||
"sha256:9eecde82ee37772764d6237b7784912241d0b93292f72ff29a921f33842691ca",
|
|
||||||
"sha256:a435b280afcba7a1ca7203a60b198d8f93d874db0ffed13ee537c5066160b429",
|
|
||||||
"sha256:ab75ad31257d2238673bde7d402c2e7608e37a8042350ca7fd51f70382a1a638"
|
|
||||||
],
|
|
||||||
"index": "pypi",
|
|
||||||
"version": "==0.7.6"
|
|
||||||
},
|
|
||||||
"toml": {
|
|
||||||
"hashes": [
|
|
||||||
"sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c",
|
|
||||||
"sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e"
|
|
||||||
],
|
|
||||||
"version": "==0.10.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
15
test.py
15
test.py
|
@ -1,5 +1,20 @@
|
||||||
import unit_converter
|
import unit_converter
|
||||||
|
|
||||||
|
|
||||||
|
def python_unit_converter(celsius):
|
||||||
|
return celsius * 1.8 + 32.0
|
||||||
|
|
||||||
|
|
||||||
def test_using_unit_converter():
|
def test_using_unit_converter():
|
||||||
assert unit_converter.convert_celsius_to_fahrenheit(25.0) == 77.0
|
assert unit_converter.convert_celsius_to_fahrenheit(25.0) == 77.0
|
||||||
|
assert python_unit_converter(25.0) == 77.0
|
||||||
|
|
||||||
|
|
||||||
|
def test_using_python(benchmark):
|
||||||
|
result = benchmark(python_unit_converter, 25.0)
|
||||||
|
assert result == 77.0
|
||||||
|
|
||||||
|
|
||||||
|
def test_using_rust(benchmark):
|
||||||
|
result = benchmark(unit_converter.convert_celsius_to_fahrenheit, 25.0)
|
||||||
|
assert result == 77.0
|
||||||
|
|
Loading…
Reference in New Issue