diff --git a/test/test_speed.py b/test/test_speed.py index b84e1f37ea4214d5421ca6ee030d6213cdbaa6ba..e32f34be04dc4511879ec63755314627caa9f1f6 100644 --- a/test/test_speed.py +++ b/test/test_speed.py @@ -3,21 +3,21 @@ numpy.random.seed(0) import time import cProfile import pstats +import collections import pandas from mhcflurry import Class1AffinityPredictor +from mhcflurry.encodable_sequences import EncodableSequences from mhcflurry.common import random_peptides -NUM = 10000 - DOWNLOADED_PREDICTOR = Class1AffinityPredictor.load() def test_speed(profile=False): - starts = {} - timings = {} - profilers = {} + starts = collections.OrderedDict() + timings = collections.OrderedDict() + profilers = collections.OrderedDict() def start(name): starts[name] = time.time() @@ -30,6 +30,8 @@ def test_speed(profile=False): if profile: profilers[name].disable() + NUM = 10000 + start("first") DOWNLOADED_PREDICTOR.predict(["SIINFEKL"], allele="HLA-A*02:01") end("first") @@ -39,6 +41,16 @@ def test_speed(profile=False): DOWNLOADED_PREDICTOR.predict(peptides, allele="HLA-A*02:01") end("pred_%d" % NUM) + NUM2 = 10000 + peptides = EncodableSequences.create(random_peptides(NUM2, length=13)) + start("encode_blosum_%d" % NUM2) + peptides.variable_length_to_fixed_length_vector_encoding("BLOSUM62") + end("encode_blosum_%d" % NUM2) + + start("pred_already_encoded_%d" % NUM2) + DOWNLOADED_PREDICTOR.predict(peptides, allele="HLA-A*02:01") + end("pred_already_encoded_%d" % NUM2) + print("SPEED BENCHMARK") print("Results:\n%s" % str(pandas.Series(timings)))