-"""Simple timer. Great for finding out how long code takes to execute.
+"""stopwatch is a very simple python module for measuring time.
+Great for finding out how long code takes to execute.
>>> t = stopwatch.Timer()
+__author__ = 'John Paulett <http://blog.7oars.com>'
- self.__start =
+ self.__start = time()
- self.__stopped = self.__time()
+ """Stops the clock permanently for the instance of the Timer.
+ Returns the time at which the instance was stopped.
+ self.__stopped = self.__last_time()
- return self.__time() - self.__start
+ """The number of seconds since the current time that the Timer
+ object was created. If stop() was called, it is the number
+ of seconds from the instance creation until stop() was called.
+ return self.__last_time() - self.__start
+ elapsed = property(elapsed)
+ """The time at which the Timer instance was created.
+ start_time = property(start_time)
+ """The time at which stop() was called, or None if stop was
+ stop_time = property(stop_time)
+ """Return the current time or the time at which stop() was call,
if self.__stopped is not None:
+ """Wrapper for time.time() to allow unit testing.
+ """Nicely format the elapsed time
return str(self.elapsed) + ' sec'