-
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.
Merge pull request #9 from unexcellent/performance_improvements
Performance improvements
- Loading branch information
Showing
6 changed files
with
323 additions
and
188 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import pytest | ||
import numpy as np | ||
|
||
from quantio import Length, Vector | ||
|
||
|
||
def bench_from_numpy__base_unit(benchmark): | ||
f = lambda: Vector.from_numpy(np.ones(100), Length, "meters") | ||
benchmark.pedantic(f, iterations=100, rounds=100) | ||
|
||
|
||
def bench_from_numpy__other_unit(benchmark): | ||
f = lambda: Vector.from_numpy(np.ones(100), Length, "centimeters") | ||
benchmark.pedantic(f, iterations=100, rounds=100) | ||
|
||
|
||
def bench_to_numpy__base_unit(benchmark): | ||
vector = Vector.from_numpy(np.ones(100), Length, "meters") | ||
f = lambda: vector.to_numpy("meters") | ||
benchmark.pedantic(f, iterations=100, rounds=100) | ||
|
||
|
||
def bench_to_numpy__other_unit(benchmark): | ||
vector = Vector.from_numpy(np.ones(100), Length, "meters") | ||
f = lambda: vector.to_numpy("centimeters") | ||
benchmark.pedantic(f, iterations=100, rounds=100) | ||
|
||
|
||
def bench_add(benchmark): | ||
vector1 = Vector.from_numpy(np.ones(100), Length, "meters") | ||
vector2 = Vector.from_numpy(np.ones(100), Length, "meters") | ||
f = lambda: vector1 + vector2 | ||
benchmark.pedantic(f, iterations=100, rounds=100) | ||
|
||
|
||
def bench_sub(benchmark): | ||
vector1 = Vector.from_numpy(np.ones(100), Length, "meters") | ||
vector2 = Vector.from_numpy(np.ones(100), Length, "meters") | ||
f = lambda: vector1 - vector2 | ||
benchmark.pedantic(f, iterations=100, rounds=100) | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main([__file__, "-v"]) |
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
Oops, something went wrong.