-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
59 additions
and
32 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
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 |
---|---|---|
@@ -1,39 +1,48 @@ | ||
""" | ||
Benchmarks. | ||
""" | ||
|
||
import time | ||
import chemics as cm | ||
|
||
|
||
def run_benchmarks(): | ||
""" | ||
Run benchmarks for the Gas methods. Elapsed time for subsequent method | ||
calls should be near zero compared to the initial method execution. | ||
""" | ||
Run benchmarks for Gas methods. | ||
gas = cm.Gas('CH4', 890.5, 120325) | ||
Run benchmarks for Gas heat capacity, thermal conductivity, and viscosity | ||
methods. Elapsed time for subsequent method calls should be near zero | ||
compared to the initial method execution. | ||
""" | ||
gas = cm.Gas("CH4", 890.5, 120325) | ||
|
||
for i in range(5): | ||
tic = time.perf_counter() | ||
cp = gas.heat_capacity() | ||
toc = time.perf_counter() | ||
print(f'Run {i + 1}, Elapsed time {toc - tic:.4f} s, cp {cp:.4f}') | ||
print(f"Run {i + 1}, Elapsed time {toc - tic:.4f} s, cp {cp:.4f}") | ||
print() | ||
|
||
for i in range(5): | ||
tic = time.perf_counter() | ||
k = gas.thermal_conductivity() | ||
toc = time.perf_counter() | ||
print(f'Run {i + 1}, Elapsed time {toc - tic:.4f} s, k {k:.4f}') | ||
print(f"Run {i + 1}, Elapsed time {toc - tic:.4f} s, k {k:.4f}") | ||
print() | ||
|
||
for i in range(5): | ||
tic = time.perf_counter() | ||
mu = gas.viscosity() | ||
toc = time.perf_counter() | ||
print(f'Run {i + 1}, Elapsed time {toc - tic:.4f} s, mu {mu:.4f}') | ||
print(f"Run {i + 1}, Elapsed time {toc - tic:.4f} s, mu {mu:.4f}") | ||
|
||
|
||
def main(): | ||
""" | ||
Run the benchmarks. | ||
""" | ||
run_benchmarks() | ||
|
||
|
||
if __name__ == '__main__': | ||
if __name__ == "__main__": | ||
main() |
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