[mlpack-svn] r15388 - mlpack/conf/jenkins-conf/benchmark/util
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Jul 3 10:22:09 EDT 2013
Author: marcus
Date: Wed Jul 3 10:22:09 2013
New Revision: 15388
Log:
Add timer class to measure time in python.
Added:
mlpack/conf/jenkins-conf/benchmark/util/timer.py
Added: mlpack/conf/jenkins-conf/benchmark/util/timer.py
==============================================================================
--- (empty file)
+++ mlpack/conf/jenkins-conf/benchmark/util/timer.py Wed Jul 3 10:22:09 2013
@@ -0,0 +1,31 @@
+'''
+ @file log.py
+ @author Marcus Edel
+
+ Implementation of the timer class.
+'''
+
+from __future__ import with_statement
+import time
+
+'''
+This class implements three functions to measure the time.
+'''
+class Timer(object):
+ '''
+ Start the timer.
+ '''
+ def __enter__(self):
+ self.__start = time.time()
+
+ '''
+ Stop the timer.
+ '''
+ def __exit__(self, type, value, traceback):
+ self.__finish = time.time()
+
+ '''
+ Return the elapsed time of the timer.
+ '''
+ def ElapsedTime(self):
+ return self.__finish - self.__start
\ No newline at end of file
More information about the mlpack-svn
mailing list