-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct threshold calc bug; Move perf test into separate file
- Loading branch information
1 parent
0914364
commit 36fad44
Showing
5 changed files
with
222 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[flake8] | ||
ignore = D203, E125, E121 | ||
ignore = D203, E125, E121, W503 |
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,34 @@ | ||
import sys | ||
import os | ||
import time | ||
import numpy as np | ||
|
||
sys.path.insert(0, os.path.abspath('..')) | ||
from pymuscle import PotvinMuscle # noqa | ||
|
||
muscle = PotvinMuscle(120, True) | ||
|
||
# Performance Benchmarking | ||
start = time.time() | ||
iterations = 10000 | ||
step_size = 1 / 50.0 | ||
for _ in range(iterations): | ||
excitation = np.random.random_integers(1, 60) / 1.0 # Quick cast | ||
force = muscle.step(excitation, step_size) | ||
duration = time.time() - start | ||
avg = duration / iterations | ||
|
||
multiple = 100 | ||
real = 1.0 / 60.0 | ||
x_real = real / multiple | ||
|
||
print("{} iterations took {} seconds. {} per iteration".format( | ||
iterations, duration, avg) | ||
) | ||
|
||
if avg < x_real: | ||
print("This is better than {}x real time :)".format(multiple)) | ||
else: | ||
print("This is worse than {}x real time. :(".format(multiple)) | ||
|
||
print("Multiple:", real / avg) |
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.