diff scripts/performance-lcss.py @ 730:a850a4f92735 dev

added performance script comparing lcss using cdist with default
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Tue, 11 Aug 2015 10:52:04 -0400
parents
children 933670761a57
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/performance-lcss.py	Tue Aug 11 10:52:04 2015 -0400
@@ -0,0 +1,12 @@
+#! /usr/bin/env python
+
+import timeit
+
+vectorLength = 10
+number = 10
+
+print('Default Python implementation with lambda')
+print timeit.timeit('lcss.compute(random_sample(({},2)), random_sample(({}, 2)))'.format(vectorLength, vectorLength*2), setup = 'from utils import LCSS; from numpy.random import random_sample; lcss = LCSS(similarityFunc = lambda x,y: (abs(x[0]-y[0]) <= 0.1) and (abs(x[1]-y[1]) <= 0.1));', number = number)
+
+print('Using scipy distance.cdist')
+print timeit.timeit('lcss.compute(random_sample(({},2)), random_sample(({}, 2)))'.format(vectorLength, vectorLength*2), setup = 'from utils import LCSS; from numpy.random import random_sample; lcss = LCSS(metric = "cityblock", epsilon = 0.1);', number = number)