Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
John Sun committed Apr 8, 2014
1 parent 25a7c33 commit 99f9e3c
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 10 deletions.
36 changes: 26 additions & 10 deletions SimpleCV/tests/test_vimba_manyshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,14 @@ def _takeShots(cam, numPics, filename):
print "Taking %d photos..." % numPics
for i in range(numPics):
img = cam.getImage()
img.save("%s_%d.png" % (filename, i))
if (i % 100 == 0):
print "At %d" % i
#img.save("%s_%d.png" % (filename, i))
end = time.time()
elapsed = end - start
print "Took %f seconds" % elapsed

"""
def test_takeManyShots():
c = VimbaCamera()
printPrettyHeader("Test takeManyShots")
_takeShots(c, 50, "vimba")
"""

def test_oneGrayShot():
c = VimbaCamera(properties={"mode":"gray"})
printPrettyHeader("Test oneGrayShot")
Expand All @@ -53,11 +48,32 @@ def test_oneShot():
img = c.getImage()
img.save("test_oneShot.png")
"""

"""
def test_takeManyShots():
c = VimbaCamera()
printPrettyHeader("Test takeManyShots")
_takeShots(c, 100, "vimba")
"""

def test_makeLotsOfCamera():
numIter = 1000
print "Creating %d cameras..." % numIter
start = time.time()
for i in range(numIter):
print "At camera=%d" % i
cam = VimbaCamera()
img = cam.getImage()
end = time.time()
elapsed = end - start
print "Took %f seconds" % elapsed

"""
def test_AVT_takeManyShots():
c = AVTCamera()
printPrettyHeader("Test AVT_takeManyShots")
_takeShots(c, 50, "avtnative")
"""
_takeShots(c, 10, "avtnative")
"""
63 changes: 63 additions & 0 deletions SimpleCV/tests/test_vimba_memory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import gc
# From bytes.com/topic/python/answers/22097-hunting-memory-leak

import time
from SimpleCV.Camera import VimbaCamera, AVTCamera

"""
# at the beginning of code
gc.enable()
gc.set_debug(gc.DEBUG_LEAK)
"""

def printPrettyHeader(msg):
print "*"*80 + "\n* %s *\n" % msg + "*"*80

def _takeShots(cam, numPics, filename):
start = time.time()
#print "Taking %d photos..." % numPics
for i in range(numPics):
img = cam.getImage()
#if (i % 1000 == 0):
# img.save("%s_%d.png" % (filename, i))
end = time.time()
elapsed = end - start
print "Took %f seconds" % elapsed

def test_takeManyShots(idx):
c = VimbaCamera()
#printPrettyHeader("Test takeManyShots %d" % idx)
print "Test takeManyShots %d" % idx

_takeShots(c, 1, "vimba%d" % idx)

def test_takeAVTManyShots(idx):
c = AVTCamera()
printPrettyHeader("Test takeAVTShots %d" % idx)

_takeShots(c, 1, "avtnative%d" % idx)

#test_takeAVTManyShots(1)
#test_takeAVTManyShots(2)
#test_takeManyShots(1)
#test_takeManyShots(2)

def test_createManyCameras():
printPrettyHeader("Test createManyCameras")
numIter = 1000
for i in range(numIter):
test_takeManyShots(i)

test_createManyCameras()

"""
########################################################################3
# at the end of code:
print "\nGARBAGE:"
gc.collect()
print "\nGARBAGE OBJECTS:"
for x in gc.garbage:
s = str(x)
print type(x),"\n",s
"""

0 comments on commit 99f9e3c

Please sign in to comment.