Skip to content

Commit

Permalink
Moved compat.py to new dir utils/ and also added timer class
Browse files Browse the repository at this point in the history
  • Loading branch information
blitzmann committed Nov 30, 2014
1 parent 8351b0f commit 8df7593
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion eos/gamedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
try:
from collections import OrderedDict
except ImportError:
from gui.utils.compat import OrderedDict
from utils.compat import OrderedDict

class Effect(EqBase):
'''
Expand Down
2 changes: 1 addition & 1 deletion eos/saveddata/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
try:
from collections import OrderedDict
except ImportError:
from gui.utils.compat import OrderedDict
from utils.compat import OrderedDict

class Fit(object):
"""Represents a fitting, with modules, ship, implants, etc."""
Expand Down
2 changes: 1 addition & 1 deletion gui/bitmapLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
try:
from collections import OrderedDict
except ImportError:
from gui.utils.compat import OrderedDict
from utils.compat import OrderedDict

cachedBitmapsCount = 0
cachedBitmaps = OrderedDict()
Expand Down
2 changes: 1 addition & 1 deletion gui/builtinStatsViews/targetingMiscViewFull.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
try:
from collections import OrderedDict
except ImportError:
from gui.utils.compat import OrderedDict
from utils.compat import OrderedDict

class TargetingMiscViewFull(StatsView):
name = "targetingmiscViewFull"
Expand Down
2 changes: 1 addition & 1 deletion gui/itemStats.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
try:
from collections import OrderedDict
except ImportError:
from gui.utils.compat import OrderedDict
from utils.compat import OrderedDict

class ItemStatsDialog(wx.Dialog):
counter = 0
Expand Down
2 changes: 1 addition & 1 deletion service/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
try:
from collections import OrderedDict
except ImportError:
from gui.utils.compat import OrderedDict
from utils.compat import OrderedDict

# Event which tells threads dependent on Market that it's initialized
mktRdy = threading.Event()
Expand Down
2 changes: 1 addition & 1 deletion service/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
try:
from collections import OrderedDict
except ImportError:
from gui.utils.compat import OrderedDict
from utils.compat import OrderedDict

FIT_WIN_HEADINGS = ["High power", "Medium power", "Low power", "Rig Slot", "Sub System", "Charges"]
EFT_SLOT_ORDER = [Slot.LOW, Slot.MED, Slot.HIGH, Slot.RIG, Slot.SUBSYSTEM]
Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions utils/timer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import time

class Timer(object):
"""
Generic timing class for simple profiling.
Usage:
with Timer(verbose=True) as t:
# code to be timed
time.sleep(5)
Output:
elapsed time: 5000.000 ms
Can also access time with t.secs
"""
def __init__(self, verbose=False):
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 'elapsed time: %f ms' % self.msecs

0 comments on commit 8df7593

Please sign in to comment.