summaryrefslogtreecommitdiff
path: root/numpy/testing/utils.py
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2006-05-24 08:59:29 +0000
committerPearu Peterson <pearu.peterson@gmail.com>2006-05-24 08:59:29 +0000
commitf3d3c4bc5b59da6dc9cd0343aeaf523a71521408 (patch)
tree403adc0cec3d5dd8d84358db4fa60fa7ac95137c /numpy/testing/utils.py
parent95d1996b0d4c3bc87d608561769d12667d82f25b (diff)
downloadnumpy-f3d3c4bc5b59da6dc9cd0343aeaf523a71521408.tar.gz
Removed win32all dependence from numpy/testing/utils.py
Diffstat (limited to 'numpy/testing/utils.py')
-rw-r--r--numpy/testing/utils.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index d95d6a19e..72e16c6b6 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -62,14 +62,12 @@ else:
return int(100*(time.time()-_load_time[0]))
def memusage():
""" Return memory usage of running python. [Not implemented]"""
- return
+ raise NotImplementedError
if os.name=='nt' and sys.version[:3] > '2.3':
- # Code stolen from enthought/debug/memusage.py
- import win32pdh
- # from win32pdhutil, part of the win32all package
+ # Code "stolen" from enthought/debug/memusage.py
def GetPerformanceAttributes(object, counter, instance = None,
- inum=-1, format = win32pdh.PDH_FMT_LONG, machine=None):
+ inum=-1, format = None, machine=None):
# NOTE: Many counters require 2 samples to give accurate results,
# including "% Processor Time" (as by definition, at any instant, a
# thread's CPU usage is either 0 or 100). To read counters like this,
@@ -78,6 +76,8 @@ if os.name=='nt' and sys.version[:3] > '2.3':
# See http://msdn.microsoft.com/library/en-us/dnperfmo/html/perfmonpt2.asp
# My older explanation for this was that the "AddCounter" process forced
# the CPU to 100%, but the above makes more sense :)
+ import win32pdh
+ if format is None: format = win32pdh.PDH_FMT_LONG
path = win32pdh.MakeCounterPath( (machine,object,instance, None, inum,counter) )
hq = win32pdh.OpenQuery()
try:
@@ -91,10 +91,12 @@ if os.name=='nt' and sys.version[:3] > '2.3':
finally:
win32pdh.CloseQuery(hq)
- def memusage(processName="python", instance=0):
- return GetPerformanceAttributes("Process", "Virtual Bytes",
- processName, instance,
- win32pdh.PDH_FMT_LONG, None)
+ def memusage(processName="python", instance=0):
+ # from win32pdhutil, part of the win32all package
+ import win32pdh
+ return GetPerformanceAttributes("Process", "Virtual Bytes",
+ processName, instance,
+ win32pdh.PDH_FMT_LONG, None)
def assert_equal(actual,desired,err_msg='',verbose=1):
""" Raise an assertion if two items are not