-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better benchmarking, fixed benchmarking bug, new comparison script.
- New scripts/benchmark_summary.py for comparing bedtools/granges. - Fixed TSV output bug.
- Loading branch information
Showing
4 changed files
with
126 additions
and
46 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,53 @@ | ||
import os | ||
import json | ||
|
||
|
||
def extract_mean_point_estimate(estimates_path): | ||
with open(estimates_path, "r") as file: | ||
data = json.load(file) | ||
return data["mean"]["point_estimate"] | ||
|
||
|
||
def calculate_ratios(criterion_dir): | ||
comparisons = {} # Store comparison: ratio | ||
|
||
subcommand_benches = [d for d in os.listdir(criterion_dir) if d != "report"] | ||
|
||
for subcommand in subcommand_benches: | ||
benches = dict() | ||
runs = os.listdir(os.path.join(criterion_dir, subcommand)) | ||
|
||
for dir in runs: | ||
if dir.startswith("report"): | ||
continue | ||
if dir.startswith("bedtools"): | ||
bedtools_bench = os.path.join( | ||
criterion_dir, subcommand, dir, "new", "estimates.json" | ||
) | ||
benches["bedtools"] = extract_mean_point_estimate(bedtools_bench) | ||
if dir.startswith("granges"): | ||
granges_bench = os.path.join( | ||
criterion_dir, subcommand, dir, "new", "estimates.json" | ||
) | ||
benches["granges"] = extract_mean_point_estimate(granges_bench) | ||
comparisons[subcommand] = benches | ||
|
||
# Calculate and print ratios for each comparison | ||
for comparison, tools in comparisons.items(): | ||
if len(tools) == 2: | ||
bedtools_time, granges_time = tools.values() | ||
# Calculate the ratio and convert it to a percentage | ||
percent_faster = ((bedtools_time - granges_time) / bedtools_time) * 100 | ||
# Format the output to show 3 decimal places | ||
print( | ||
f"{comparison} - Granges is {percent_faster:.3f}% faster than Bedtools" | ||
) | ||
|
||
|
||
def main(): | ||
criterion_dir = "target/criterion" | ||
calculate_ratios(criterion_dir) | ||
|
||
|
||
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