Moved compat.py to new dir utils/ and also added timer class
This commit is contained in:
@@ -28,7 +28,7 @@ import traceback
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from gui.utils.compat import OrderedDict
|
||||
from utils.compat import OrderedDict
|
||||
|
||||
class Effect(EqBase):
|
||||
'''
|
||||
|
||||
@@ -32,7 +32,7 @@ import time
|
||||
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."""
|
||||
|
||||
@@ -25,7 +25,7 @@ import time
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from gui.utils.compat import OrderedDict
|
||||
from utils.compat import OrderedDict
|
||||
|
||||
cachedBitmapsCount = 0
|
||||
cachedBitmaps = OrderedDict()
|
||||
|
||||
@@ -26,7 +26,7 @@ import locale
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from gui.utils.compat import OrderedDict
|
||||
from utils.compat import OrderedDict
|
||||
|
||||
class TargetingMiscViewFull(StatsView):
|
||||
name = "targetingmiscViewFull"
|
||||
|
||||
@@ -32,7 +32,7 @@ import config
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
from gui.utils.compat import OrderedDict
|
||||
from utils.compat import OrderedDict
|
||||
|
||||
class ItemStatsDialog(wx.Dialog):
|
||||
counter = 0
|
||||
|
||||
@@ -32,7 +32,7 @@ import service.conversions as conversions
|
||||
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()
|
||||
|
||||
@@ -27,7 +27,7 @@ import service
|
||||
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]
|
||||
|
||||
30
utils/timer.py
Normal file
30
utils/timer.py
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user