This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
# Simple Timer | |
class Timer: | |
def __init__(self): | |
self.reset() | |
def reset(self): | |
self._start = time.time() | |
def elapsed(self): # elapsed time in seconds (float) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper class for statistics | |
# see: http://www.johndcook.com/blog/standard_deviation/ | |
class Stats: | |
""" Uses Welford's method to calculate stats. | |
Assumes positive values. | |
It's not thread safe | |
stats = Stats("ConnectionTimeStats") | |
stats.add(0.223) | |
stats.add(1.343) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |