Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devtools/ScaleTypeTest/scaleTest.py
diff options
context:
space:
mode:
authorslm <-h>2010-07-07 10:39:15 (GMT)
committer slm <-h>2010-07-07 10:39:15 (GMT)
commit9a5cc0c5cf88490eaf8da338af8945f5caeb88e6 (patch)
treeb901a011b9601b4e486ec59b5bb4b9ece1941f28 /devtools/ScaleTypeTest/scaleTest.py
parente77d946392133d238efba5cda41b868ff8f7919f (diff)
Have completed a prototype of the complete test kit UI which allows you to set up multiple tests at once and then leave the computer as they execute one after another. Final values are exported to a formatted comma seperated values file for convenience. Commenting is moderate and will have to be expanded upon in the future.
Diffstat (limited to 'devtools/ScaleTypeTest/scaleTest.py')
-rwxr-xr-xdevtools/ScaleTypeTest/scaleTest.py124
1 files changed, 56 insertions, 68 deletions
diff --git a/devtools/ScaleTypeTest/scaleTest.py b/devtools/ScaleTypeTest/scaleTest.py
index c0fccd9..42212db 100755
--- a/devtools/ScaleTypeTest/scaleTest.py
+++ b/devtools/ScaleTypeTest/scaleTest.py
@@ -6,8 +6,6 @@ print "Scale Test - Authors Dave Silverman and Scott Mengel"
print "Set size window to 600 x 400 px"
print "Running..."
-
-
#--------------------------------------------------------------
#CONSTANTS AND VARIABLES
@@ -23,60 +21,48 @@ size = width, height = 600,400 #screen sizes
t=0 #trial number n
colorkey=(255, 152, 0)
-ftArr=[ ["bmp","BMP16100/"] , ["bmp","BMP16173/"] , ["bmp","BMP16200/"] , ["bmp","BMP16400/"] ,["bmp","BMP24100/"] , ["bmp","BMP24173/"] , ["bmp","BMP24200/"] , ["bmp","BMP24400/"] , ["gif","GIF100/"] , ["gif","GIF173/"] , ["gif","GIF200/"] , ["gif","GIF400/"] , ["gif","GIFT100/"] , ["gif","GIFT173/"] , ["gif","GIFT200/"] , ["gif","GIFT400/"] , ["png","PNG100/"] , ["png","PNG173/"] , ["png","PNG200/"] , ["png","PNG400/"] , ["png","PNGT100/"] , ["png","PNGT173/"] , ["png","PNGT200/"] , ["png","PNGT400/"] ]
+ftArr=[ ["bmp","BMP16100/"] ,
+ ["bmp","BMP16173/"] ,
+ ["bmp","BMP16200/"] ,
+ ["bmp","BMP16400/"] ,
+ ["bmp","BMP24100/"] ,
+ ["bmp","BMP24173/"] ,
+ ["bmp","BMP24200/"] ,
+ ["bmp","BMP24400/"] ,
+ ["gif","GIF100/"] ,
+ ["gif","GIF173/"] ,
+ ["gif","GIF200/"] ,
+ ["gif","GIF400/"] ,
+ ["gif","GIFT100/"] ,
+ ["gif","GIFT173/"] ,
+ ["gif","GIFT200/"] ,
+ ["gif","GIFT400/"] ,
+ ["png","PNG100/"] ,
+ ["png","PNG173/"] ,
+ ["png","PNG200/"] ,
+ ["png","PNG400/"] ,
+ ["png","PNGT100/"] ,
+ ["png","PNGT173/"] ,
+ ["png","PNGT200/"] ,
+ ["png","PNGT400/"] ]
screen = pygame.display.set_mode(size) #Screen Set 600x400
background = 152, 251, 152 # pale green
+#23456789123456789212345678931234567894123456789512345678961234567897123456789*
-#-------------------------------------------------------------
-#The switch function
-
-def chngImg():
- cnt=make
- while cnt>0:
- """switcher = {
- 1: pygame.transform.scale( pygame.image.load( "%s2.%s"%( ft[1],ft[0] ) ) ,(sizeTo[0],sizeTo[1] ),
- 2: pygame.transform.scale( pygame.image.load("%s3.%s"%(ft[1],ft[0])),(sizeTo[0],sizeTo[1] ),
- 3: pygame.transform.scale( pygame.image.load("%s4.%s"%(ft[1],ft[0])),(sizeTo[0],sizeTo[1] ),
- 4: pygame.transform.scale( pygame.image.load("%s5.%s"%(ft[1],ft[0])),(sizeTo[0],sizeTo[1] ),
- 5: pygame.transform.scale( pygame.image.load("%s6.%s"%(ft[1],ft[0])),(sizeTo[0],sizeTo[1] ),
- 6: pygame.transform.scale( pygame.image.load("%s7.%s"%(ft[1],ft[0])),(sizeTo[0],sizeTo[1] ),
- 7: pygame.transform.scale( pygame.image.load("%s8.%s"%(ft[1],ft[0])),(sizeTo[0],sizeTo[1] ),
- 8: pygame.transform.scale( pygame.image.load("%s9.%s"%(ft[1],ft[0])),(sizeTo[0],sizeTo[1] ),
- 9: pygame.transform.scale( pygame.image.load("%s1.%s"%(ft[1],ft[0])),(sizeTo[0],sizeTo[1] )
- }
- """
- img[cnt,0]=switcher.get(i,pygame.image.load("%s1.%s"%(ft[1],ft[0])))
-# img[cnt,0] = pygame.transform.scale(img[cnt,0],(sizeTo[0], sizeTo[1]))
- cnt=cnt-1
-
-#-----------------------------------------------------------------
-#- Collision detection -------------------------------------------
-
-def collision():
- cnt=make
- while cnt>0:
- if img[cnt,1].left < 0 or img[cnt,1].right > width:
- img[cnt,2]=[ -img[cnt,2][0], img[cnt,2][1] ]
- if img[cnt,1].top < 0 or img[cnt,1].bottom > height:
- img[cnt,2]=[ img[cnt,2][0], -img[cnt,2][1] ]
- img[cnt,1] = img[cnt,1].move(img[cnt,2])
- screen.blit(img[cnt,0],img[cnt,1])
- cnt=cnt-1
- pygame.display.flip()
-
-
-#-----------------------------------------------------------------
-#- Number of dashed lined relates to loops -----------------------
-
+# This is the beginning of the actual test loops; this program is a very rough
+# learning exercise which we desire to polish to such a state that it can be
+# used to accurately benchmark the XO laptop's speed capabilities
while 1:
cnt=make
ft=ftArr[t]
print "Testing: "+ft[1]+" extension "+ft[0]
trialthis=trial
- start=time.time()
+ start=time.time()
+# This timer will reflect the time taken to load and resize images in memory
switcher = {
+# This is also where we need advise regarding implementing convert()
1: pygame.transform.scale( pygame.image.load("%s2.%s"%(ft[1],ft[0])).convert(),(sizeTo[0],sizeTo[1] )),
2: pygame.transform.scale( pygame.image.load("%s3.%s"%(ft[1],ft[0])).convert(),(sizeTo[0],sizeTo[1] )),
3: pygame.transform.scale( pygame.image.load("%s4.%s"%(ft[1],ft[0])).convert(),(sizeTo[0],sizeTo[1] )),
@@ -91,43 +77,45 @@ while 1:
print sizeTo
print " pixels was "
print time.time()-start
-
-#-----------------------------------------------------------------
+# Here ends the loading section, and hereafter we jump into the main loop
while trialthis>0:
-
- #-------------------------------------------------------------
- while cnt>0:
- img[cnt,0]= pygame.image.load("%s1.%s"%(ft[1],ft[0])) #image.load
+ while cnt>0:
+# establish the initial state for the images of the next trial
+ img[cnt,0]= pygame.image.load("%s1.%s"%(ft[1],ft[0]))
img[cnt,0]= pygame.transform.scale(img[cnt,0],(sizeTo[0], sizeTo[1]))
img[cnt,1]= img[cnt,0].get_rect()
img[cnt,2]= [2,2] #speed
- m=cnt*40 # named m cause i wanted some m&ms
- img[cnt,1]=img[cnt,1].move(m,m) #see? it wasn't as tastey though
+ m=cnt*40
+# Here I move images to avoid indistinguishable stacks of image rectangles
+ img[cnt,1]=img[cnt,1].move(m,m)
cnt=cnt-1
-
- #-------------------------------------------------------------
r=0
start=time.time()
- #-------------------------------------------------------------
while 1:
- chngImg()
+# This loop is the 'main event' so to speak, as it is the section that is
+# measured in terms of frames per second
+
+ cnt=make # For each 'ball' icon loaded
+ while cnt>0: # Cycle and check if the 'ball' should bounce off the wall
+ print cnt
+ img[cnt,0]=switcher.get(i,None)
+ if img[cnt,1].left < 0 or img[cnt,1].right > width:
+ img[cnt,2]=[ -img[cnt,2][0], img[cnt,2][1] ]
+ if img[cnt,1].top < 0 or img[cnt,1].bottom > height:
+ img[cnt,2]=[ img[cnt,2][0], -img[cnt,2][1] ]
+ img[cnt,1] = img[cnt,1].move(img[cnt,2])
+# Move the 'ball' image accordingly, plot the change
+ screen.blit(img[cnt,0],img[cnt,1])
+ cnt=cnt-1
+ pygame.display.flip()
+# "Make it so, number two," on those changes above
i=i+1
if i>9: i=1
-
- collision()
screen.fill(background)
-
r=r+1
if r>500: break
-
- #-------------------------------------------------------------
+# After 500 frames, we print the average frame rate to the terminal
print 1/((time.time()-start)/r)
trialthis=trialthis-1
-
-#-----------------------------------------------------------------
t=t+1
- print ""
-
-#-----------------------------------------------------------------
-#-----------------------------------------------------------------