/[gzz]/gzz/gfx/demo/coords_benchmark.py
ViewVC logotype

Diff of /gzz/gfx/demo/coords_benchmark.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by mudyc, Thu Mar 13 15:31:04 2003 UTC revision 1.4 by mudyc, Tue Mar 18 00:42:17 2003 UTC
# Line 31  dbg = 1 Line 31  dbg = 1
31    
32  class ViewScene:  class ViewScene:
33      def __init__(self):      def __init__(self):
34          self.passes = 0          self.nested = 0
35          self.time = 0          self.count = 500
36          self.diff = 0          self.letters = 0
37            
38      def scene(self, vs):      def scene(self, vs):
39          size = vs.getSize()          size = vs.getSize()
# Line 48  class ViewScene: Line 48  class ViewScene:
48          bgcolor = (0.6, 0.7, 0.8)          bgcolor = (0.6, 0.7, 0.8)
49          putnoc(vs, background(bgcolor))          putnoc(vs, background(bgcolor))
50    
51            alph = 'abcdefghijklmnopqrstuvwxyz'
52    
53          # clipping area          # clipping area
54          clip = vs.orthoCS(0,"CLIP",0, #0,0, size.width, size.height)          clip = vs.orthoCS(0,"CLIP",0, 0,0, size.width, size.height)
55                            size.width*1/20, size.height*1/20,          tr = vs.translateCS(0, 'tr', movx,movy)
56                            size.width*9/10, size.height*9/10)  
57            if not hasattr(self, "letters"):
58          tr = vs.translateCS(0, 'tr', movx,movy)              return
59            
60          for i in range(0,self.passes):          for nested in range(0, self.nested):
61              if i%4 == 0:              if nested%4 == 0:
62                  tr = vs.translateCS(tr, 'tra'+str(i), 0, -movy)                  tr = vs.translateCS(tr, 'tra'+str(nested), 0, -movy)
63              elif i%4 == 1:              elif nested%4 == 1:
64                  tr = vs.translateCS(tr, 'trb'+str(i), -movx,0)                  tr = vs.translateCS(tr, 'trb'+str(nested), -movx,0)
65              elif i%4 == 2:              elif nested%4 == 2:
66                  tr = vs.translateCS(tr, 'trc'+str(i), 0, movy)                  tr = vs.translateCS(tr, 'trc'+str(nested), 0, movy)
67              else:              else:
68                  tr = vs.translateCS(tr, 'trd'+str(i), movx,0)                  tr = vs.translateCS(tr, 'trd'+str(nested), movx,0)
69    
70          for i in range(0,800):          for count in range(0, self.count):
71              cs = vs.translateCS(tr, 'TEXT'+str(i),              cs = vs.translateCS(tr, 'TEXT'+str(count),
72                                  r.nextFloat()*w, r.nextFloat()*h)                                  r.nextFloat()*w, r.nextFloat()*h)
73              cs = vs.cullCS(cs, 'CULL'+str(i), clip)              cs = vs.cullCS(cs, 'CULL'+str(count), clip)
74              putText(vs, cs, str(i), color=(0,0,0), h=14, y=10)              a = count % len(alph)
75          self.passes += 1              b = (count + self.letters) % len(alph)
76                string = ''
77          # count time              if a > b:
78          time = System.currentTimeMillis()                  tmp = 2*alph[:len(alph)]
79          real = time - self.time                  string = tmp[a:(b+len(alph))]
80          if real > 15*1000:              else:
81              real = 0                  string = alph[a:b]
82                            putText(vs, cs, string, color=(0,0,0), h=14, y=10)
83          if dbg:  
84              print 'Passes: ', self.passes, \  
85                    ' time: ', time - self.time, \      def benchmark(self):
86                    ' diff: ', time - self.time - self.diff          for self.nested in range(0,13,3):
87          self.diff = time - self.time              for self.count in range(100,701,200):
88          self.time = time                  for self.letters in range(1,20,4):
89                        vs = w.createVobScene()
90          if real < 1500:                      self.scene(vs)
91              AbstractUpdateManager.chg()                      AbstractUpdateManager.chg()
92          else:  
93              print 'Stop! - passes:', self.passes ,' time:', real                      print self.nested,' nested CS, ',\
94              print 'press r to rerun'                            self.count, ' text vobs, ',\
95                              self.letters, ' letters ',\
96                              'time: ', w.timeRender(vs, 100)
97                    
98        def key(self, k):
99            if k == "Ctrl-B":
100                self.benchmark()
101    
102    
103    
104  currentScene = ViewScene()  currentScene = ViewScene()

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26