Skip to content

Instantly share code, notes, and snippets.

@patrickwolf
Last active May 20, 2016 02:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patrickwolf/29652fd604e6dea5f09b to your computer and use it in GitHub Desktop.
Save patrickwolf/29652fd604e6dea5f09b to your computer and use it in GitHub Desktop.
Quick script to compare performance of sequence detection libraries
'''
Quick script to compare performance of sequence detection libraries
Created on Aug 26, 2014
Refernced libraries:
https://github.com/4degrees/clique
http://pyseq.rsgalloway.com/
@author: patrick.wolf
'''
import time
import clique
import pyseq
class Timer(object):
""" @source: http://www.huyng.com/posts/python-performance-analysis/ """
def __init__(self, name="", verbose=False):
self.name = name
self.verbose = verbose
def __enter__(self):
self.start = time.time()
return self
def __exit__(self, *args):
self.end = time.time()
self.secs = self.end - self.start
self.msecs = self.secs * 1000 # millisecs
if self.verbose:
print '%s: elapsed time: %f ms' % (self.name, self.msecs)
max = 30000
with Timer("list building (%d items)" % max, verbose=True):
filelist = ["superlong_v1.%05d.jpeg" % a for a in range(0, max)]
with Timer("list copy", verbose=True) :
a = filelist[:]
with Timer("clique", verbose=True) :
cliqueList, remainder = clique.assemble(filelist[:])
print "cliqueList: " + str(cliqueList)
with Timer("clique", verbose=True) :
cliqueList, remainder = clique.assemble(filelist[:])
print "cliqueList: " + str(cliqueList)
with Timer("pyseq", verbose=True) :
pySeqList = pyseq.Sequence(filelist[:])
print "pySeqList: " + str(pySeqList)
with Timer("pyseq", verbose=True) :
pySeqList2 = pyseq.Sequence(filelist[:])
print "pySeqList: " + str(pySeqList)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment