Skip to content

Commit

Permalink
DEV: Added runtimes script
Browse files Browse the repository at this point in the history
  • Loading branch information
niklases committed Jul 9, 2024
1 parent 9164692 commit 7f9fc93
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
Binary file added .github/imgs/runtimes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -384,3 +384,7 @@ datasets/AVGFP/Recomb_Double_Split/Recomb_Double_Split4.fasta
datasets/AVGFP/Recomb_Double_Split/Recomb_Double_Split5.fasta
datasets/AVGFP/Recomb_Double_Split/Recomb_Double_Split6.fasta
datasets/AVGFP/Recomb_Double_Split/Recomb_Double_Split7.fasta
avGFP_shortened_dca_encoded.csv
datasets/AVGFP/avGFP_shortened.csv
avGFP_dca_encoded.csv
scripts/Runtime_tests/runtimes.png
7 changes: 5 additions & 2 deletions scripts/Runtime_tests/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
TODO
## Benchmarking runtimes

CPU runtimes using multiple threads.
Wall clock runtimes for PLMC-DCA CPU-based sequence encoding (with PLMC parameter file) using multiple cores/threads.

<p align="center">
<img src="../../.github/imgs/runtimes.png" alt="drawing" width="500"/>
</p>
44 changes: 44 additions & 0 deletions scripts/Runtime_tests/os_system_runtimes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@


import os
import sys
import time
import matplotlib.pyplot as plt

pypef_path = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'../..'
)
)

sys.path.append(pypef_path)

avgfp_path = os.path.abspath(
os.path.join(
os.path.dirname(__file__),
'../../datasets/AVGFP'
)
)

# Assuming that the Conda environment 'pypef' exists and contains all necessary Python packages,
# using'avGFP_shortened.csv' instead of 'avGFP.csv' takes much less computing time
cmd = f"conda run -n pypef python {os.path.join(pypef_path, 'pypef', 'main.py')} "\
f"encode -i {os.path.join(avgfp_path, 'avGFP.csv')} "\
f"-e dca -w {os.path.join(avgfp_path, 'P42212_F64L.fasta')} "\
f"--params {os.path.join(avgfp_path, 'uref100_avgfp_jhmmer_119_plmc_42.6.params')} "\
f"--threads XX"

print(os.cpu_count())
all_run_times = []
for n_cores in range(1, os.cpu_count() + 1):
run_time_1 = time.time()
print(f"Running command:\n============\n{cmd.replace('XX', str(n_cores))}")
os.system(cmd.replace('XX', str(n_cores)))
run_time_2 = time.time()
all_run_times.append(run_time_2 - run_time_1)
plt.plot(range(1, os.cpu_count() + 1), all_run_times, 'o--')
plt.grid()
plt.xlabel('# Cores/Threads')
plt.ylabel('Runtime (s)')
plt.savefig(os.path.join(os.path.dirname(__file__), 'runtimes.png'), dpi=300)

0 comments on commit 7f9fc93

Please sign in to comment.