sbsv2/raptor/bin/timelines.py
author Ross Qin <ross.qin@nokia.com>
Tue, 30 Nov 2010 14:05:41 +0800
changeset 713 7b7f0409fc00
parent 591 22486c9c7b15
permissions -rw-r--r--
merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
591
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     1
#
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     2
# Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     3
# All rights reserved.
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     4
# This component and the accompanying materials are made available
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     6
# which accompanies this distribution, and is available
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     8
#
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
     9
# Initial Contributors:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    10
# Nokia Corporation - initial contribution.
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    11
#
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    12
# Contributors:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    13
#
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    14
# Description: 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    15
# 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    16
# Raptor log visualisation program. Takes a raptor log as standard input
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    17
# and displays timelines that represent build progress and 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    18
# how much actual parallelism there is in the build.
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    19
# This program requires the pygame and PyOpenGL modules.
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    20
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    21
from OpenGL.GL import *
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    22
from OpenGL.GLU import *
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    23
import pygame
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    24
from pygame.locals import *
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    25
import time
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    26
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    27
class Timeline(object):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    28
	"""A bar representing a number of recipes which were executed in 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    29
	   time sequence.  There is no guarantee about what host but in 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    30
	   theory they could have been executed on the same host."""
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    31
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    32
	globalmax = 2.0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    33
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    34
	def __init__(self,ylevel):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    35
		self.maxtime = 0.0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    36
		self.recipes = []
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    37
		self.ylevel = ylevel
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    38
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    39
	def append(self, recipe):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    40
		"" add this recipe to this timeline if it happens after the latest recipe already in the timeline ""
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    41
		if recipe.starttime + recipe.duration > self.maxtime:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    42
			self.maxtime = recipe.starttime + recipe.duration
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    43
			if self.maxtime > Timeline.globalmax:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    44
				Timeline.globalmax = self.maxtime 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    45
		else:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    46
			pass
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    47
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    48
		self.recipes.append(recipe)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    49
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    50
	def draw(self):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    51
		glLoadIdentity()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    52
		self.xscale = 4.0 / Timeline.globalmax
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    53
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    54
    		glTranslatef(-2.0, -1.5, -6.0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    55
		count = 0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    56
		for r in self.recipes:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    57
			if count % 2 == 0:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    58
				coloff=0.8
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    59
			else:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    60
				coloff = 1.0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    61
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    62
			count += 1
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    63
			r.draw(self.xscale, self.ylevel, coloff)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    64
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    65
class Recipe(object):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    66
	"""Represents a task completed in a raptor build. 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    67
	   Drawn as a colour-coded bar with different 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    68
	   colours for the various recipe types."""
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    69
	STAT_OK = 0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    70
	colours = {
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    71
		'compile': (0.5,0.5,1.0),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    72
		'compile2object': (0.5,0.5,1.0),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    73
		'win32compile2object': (0.5,0.5,1.0),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    74
		'tools2linkexe': (0.5,1.0,0.5),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    75
		'link': (0.5,1.0,0.5),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    76
		'linkandpostlink': (0.5,1.0,0.5),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    77
		'win32stageonelink': (0.5,1.0,0.5),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    78
		'tools2lib': (0.5,1.0,1.0),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    79
		'win32stagetwolink': (1.0,0.1,1.0),
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    80
		'postlink': (1.0,0.5,1.0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    81
		}
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    82
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    83
	def __init__(self, starttime, duration, name, status):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    84
		self.starttime = starttime
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    85
		self.duration = duration
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    86
		self.status = status
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    87
		self.colour = (1.0, 1.0, 1.0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    88
		if name in Recipe.colours:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    89
			self.colour = Recipe.colours[name]
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    90
		else:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    91
			self.colour = (1.0,1.0,1.0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    92
		self.name = name 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    93
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    94
	def draw(self, scale, ylevel, coloff):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    95
		if self.status == Recipe.STAT_OK:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    96
			glColor4f(self.colour[0]*coloff, self.colour[1]*coloff, self.colour[2]*coloff,0.2)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    97
		else:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    98
			glColor4f(1.0*coloff, 0.6*coloff, 0.6*coloff,0.2)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
    99
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   100
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   101
		x = self.starttime * scale
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   102
		y = ylevel
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   103
		x2 = x + self.duration * scale
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   104
		y2 = ylevel + 0.2
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   105
		glBegin(GL_QUADS)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   106
		glVertex3f(x, y, 0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   107
		glVertex3f(x, y2, 0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   108
		glVertex3f(x2, y2, 0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   109
		glVertex3f(x2, y, 0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   110
		glEnd()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   111
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   112
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   113
def resize((width, height)):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   114
	if height==0:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   115
		height=1
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   116
	glViewport(0, 0, width, height)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   117
	glMatrixMode(GL_PROJECTION)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   118
	glLoadIdentity()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   119
	gluPerspective(45, 1.0*width/height, 0.1, 100.0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   120
	glMatrixMode(GL_MODELVIEW)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   121
	glLoadIdentity()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   122
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   123
def init():
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   124
	glShadeModel(GL_SMOOTH)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   125
	glClearColor(0.0, 0.0, 0.0, 0.0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   126
	glClearDepth(1.0)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   127
	glEnable(GL_DEPTH_TEST)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   128
	glDepthFunc(GL_LEQUAL)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   129
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   130
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   131
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   132
import sys
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   133
import re
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   134
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   135
def main():
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   136
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   137
	video_flags = OPENGL|DOUBLEBUF
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   138
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   139
	pygame.init()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   140
	pygame.display.set_mode((800,600), video_flags)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   141
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   142
	resize((800,600))
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   143
	init()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   144
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   145
	frames = 0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   146
	ticks = pygame.time.get_ticks()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   147
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   148
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   149
	lines = 4
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   150
	timelines = []
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   151
	ylevel = 0.0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   152
	for i in xrange(0,4):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   153
		ylevel += 0.6 
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   154
		timelines.append(Timeline(ylevel))
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   155
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   156
	f = sys.stdin
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   157
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   158
	recipe_re = re.compile(".*<recipe name='([^']+)'.*")
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   159
	time_re = re.compile(".*<time start='([0-9]+\.[0-9]+)' *elapsed='([0-9]+\.[0-9]+)'.*")
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   160
	status_re = re.compile(".*<status exit='([^']*)'.*")
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   161
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   162
	alternating = 0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   163
	start_time = 0.0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   164
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   165
	
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   166
	for l in f.xreadlines():
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   167
		l2 = l.rstrip("\n")
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   168
		rm = recipe_re.match(l2)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   169
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   170
		if rm is not None:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   171
			rname = rm.groups()[0]
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   172
			continue
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   173
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   174
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   175
		tm = time_re.match(l2)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   176
		if tm is not None:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   177
			s = float(tm.groups()[0])
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   178
			elapsed = float(tm.groups()[1])
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   179
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   180
			if start_time == 0.0:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   181
				start_time = s
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   182
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   183
			s -= start_time
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   184
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   185
			continue
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   186
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   187
		sm = status_re.match(l2)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   188
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   189
		if sm is None:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   190
			continue
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   191
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   192
		if sm.groups()[0] == 'ok':
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   193
			status = 0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   194
		else:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   195
			status = int(sm.groups()[0])
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   196
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   197
		olddiff = 999999999.0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   198
		tnum = 0
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   199
		for t in timelines:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   200
			newdiff = s - t.maxtime
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   201
			if newdiff < 0.0:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   202
				continue
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   203
			if olddiff > newdiff:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   204
				dest_timeline = t
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   205
				olddiff = newdiff
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   206
			tnum += 1
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   207
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   208
		dest_timeline.append(Recipe(s, elapsed, rname, status))
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   209
		event = pygame.event.poll()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   210
		if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   211
			break
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   212
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   213
		glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   214
		for t in timelines:
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   215
			t.draw()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   216
		pygame.display.flip()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   217
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   218
		frames = frames+1
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   219
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   220
	print "fps:  %de" % ((frames*1000)/(pygame.time.get_ticks()-ticks))
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   221
	event = pygame.event.wait()
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   222
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   223
22486c9c7b15 raptor v2.14.0
jjkang
parents:
diff changeset
   224
if __name__ == '__main__': main()