Skip to content

Commit

Permalink
who needs python2 support anyways
Browse files Browse the repository at this point in the history
  • Loading branch information
Niru Maheswaranathan committed Sep 14, 2015
1 parent 01d8018 commit 00ab29b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 21 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python
sudo: false
python:
- "2.7"
- "3.4"
- "3.5"

Expand Down
37 changes: 17 additions & 20 deletions jetpack/timepiece.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""

import numpy as np
import sys
import time
from .ionic import unicodes
from functools import wraps
Expand Down Expand Up @@ -109,22 +108,20 @@ def hrtime(t):
return timestr


# python 3 only
if sys.version_info > (3,0):
def profile(func):
calls = list()
@wraps(func)
def wrapper(*args, **kwargs):
nonlocal calls
tstart = time.time()
results = func(*args, **kwargs)
tstop = time.time()
calls.append(tstop-tstart)
return results

wrapper.calls = calls
wrapper.mean = lambda: np.mean(calls)
wrapper.serr = lambda: np.std(calls) / np.sqrt(len(calls))
wrapper.summary = lambda: print('Runtimes: {} {} {}'.format(
hrtime(wrapper.mean()), unicodes['pm'], hrtime(wrapper.serr())))
return wrapper
def profile(func):
calls = list()
@wraps(func)
def wrapper(*args, **kwargs):
nonlocal calls
tstart = time.time()
results = func(*args, **kwargs)
tstop = time.time()
calls.append(tstop-tstart)
return results

wrapper.calls = calls
wrapper.mean = lambda: np.mean(calls)
wrapper.serr = lambda: np.std(calls) / np.sqrt(len(calls))
wrapper.summary = lambda: print('Runtimes: {} {} {}'.format(
hrtime(wrapper.mean()), unicodes['pm'], hrtime(wrapper.serr())))
return wrapper

0 comments on commit 00ab29b

Please sign in to comment.