From dfbfcd7d4a566ab9f0e25a3194f37007a1cdf2a0 Mon Sep 17 00:00:00 2001 From: SooLee Date: Tue, 12 Sep 2017 15:52:03 -0400 Subject: [PATCH] gb/mb conversion corrected --- Benchmark/Benchmark.py | 11 +++++++---- tests/tests_benchmark.py | 10 +++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Benchmark/Benchmark.py b/Benchmark/Benchmark.py index fc29c4b..da1e377 100644 --- a/Benchmark/Benchmark.py +++ b/Benchmark/Benchmark.py @@ -10,6 +10,9 @@ # AWS-related information including recommended_instance_type, ebs_size, EBS_optimized, etc. +GB_IN_BYTES = 1073741824 +MB_IN_BYTES = 1048576 + class BenchmarkResult(object): def __init__(self, size, mem, cpu): @@ -40,7 +43,7 @@ def md5(input_json): assert 'input_size_in_bytes' in input_json assert 'input_file' in input_json.get('input_size_in_bytes') - r = BenchmarkResult(size=input_json.get('input_size_in_bytes').get('input_file') / 1048576 + 3, + r = BenchmarkResult(size=input_json.get('input_size_in_bytes').get('input_file') / GB_IN_BYTES + 3, mem=4, cpu=1) @@ -56,7 +59,7 @@ def fastqc_0_11_4_1(input_json): if 'threads' in input_json.get('parameters'): nthreads = input_json.get('parameters').get('threads') - r = BenchmarkResult(size=input_json.get('input_size_in_bytes').get('input_fastq') / 1048576 * 2 + 3, + r = BenchmarkResult(size=input_json.get('input_size_in_bytes').get('input_fastq') / GB_IN_BYTES * 2 + 3, mem=300 * nthreads, cpu=nthreads) @@ -85,10 +88,10 @@ def bwa_mem(input_json): total_output_size = output_bam_size additional_size_in_gb = 4.5 - total_size = (total_input_size + total_intermediate_size + total_output_size) / 1048576 + additional_size_in_gb + total_size = (total_input_size + total_intermediate_size + total_output_size) / GB_IN_BYTES + additional_size_in_gb # mem - mem = input_sizes.get('bwa_index') * 4 / 1024 + mem = input_sizes.get('bwa_index') * 4 / MB_IN_BYTES r = BenchmarkResult(size=total_size, mem=mem, cpu=nthreads) diff --git a/tests/tests_benchmark.py b/tests/tests_benchmark.py index 7664af1..5ef3a3b 100644 --- a/tests/tests_benchmark.py +++ b/tests/tests_benchmark.py @@ -18,14 +18,14 @@ def test_get_optimal_instance_type2(self): class TestBenchmark(unittest.TestCase): def test_benchmark1(self): - res = B.benchmark('md5', {'input_size_in_bytes': {'input_file': 20000}}) + res = B.benchmark('md5', {'input_size_in_bytes': {'input_file': 200000000}}) assert 'aws' in res assert 'recommended_instance_type' in res['aws'] assert res['aws']['recommended_instance_type'] == 't2.nano' print(res) def test_benchmark2(self): - res = B.benchmark('fastqc-0-11-4-1', {'input_size_in_bytes': {'input_fastq': 20000}, + res = B.benchmark('fastqc-0-11-4-1', {'input_size_in_bytes': {'input_fastq': 20000000000}, 'parameters': {'threads': 2}}) assert 'aws' in res assert 'recommended_instance_type' in res['aws'] @@ -33,9 +33,9 @@ def test_benchmark2(self): print(res) def test_benchmark3(self): - input_json = {'input_size_in_bytes': {'fastq1': 93520, - 'fastq2': 97604, - 'bwa_index': 3364568}, + input_json = {'input_size_in_bytes': {'fastq1': 93520000, + 'fastq2': 97604000, + 'bwa_index': 3364568000}, 'parameters': {'nThreads': 4}} res = B.benchmark('bwa-mem', input_json) assert 'aws' in res