Skip to content
Snippets Groups Projects
Commit 1d75ca19 authored by Tim O'Donnell's avatar Tim O'Donnell
Browse files

update speed benchmark

parent 7d323a86
No related branches found
No related tags found
No related merge requests found
......@@ -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)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment