From 1d75ca19e2da25feb7216f9ea3c105805c4abb8b Mon Sep 17 00:00:00 2001
From: Tim O'Donnell <timodonnell@gmail.com>
Date: Tue, 28 Nov 2017 16:11:58 -0500
Subject: [PATCH] update speed benchmark

---
 test/test_speed.py | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/test/test_speed.py b/test/test_speed.py
index b84e1f37..e32f34be 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)))
 
-- 
GitLab