gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz gfx/jni/GzzGL-jni.cxx gfx/librenderables/Re...


From: Matti Katila
Subject: [Gzz-commits] gzz gfx/jni/GzzGL-jni.cxx gfx/librenderables/Re...
Date: Mon, 17 Mar 2003 10:42:20 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Matti Katila <address@hidden>   03/03/17 10:42:19

Modified files:
        gfx/jni        : GzzGL-jni.cxx 
        gfx/librenderables: Renderables.cxx Renderables.hxx 
        gzz/client/gl  : GLUpdateManager.java 
        gzz/gfx/gl     : GL.java 
        gzz/modules/pp : PPDemo.java PPView2.java demotest.py 
        gzz/modules/pp/vob: BgVob.java 

Log message:
        add a lot of lousy code for benchmarks.
        
        results:
        1 : Benchmark - leave out paper :      140  frames.
        2 : Benchmark - leave out shortcuts :  175  frames.
        3 : Benchmark - leave out text :       252  frames.
        4 : Benchmark - leave out background : 269  frames.
        5 : Benchmark - leave out fillet :     122  frames.
        6 : Benchmark - leave out nothing :    122  frames.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/jni/GzzGL-jni.cxx.diff?tr1=1.89&tr2=1.90&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/Renderables.cxx.diff?tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/Renderables.hxx.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/client/gl/GLUpdateManager.java.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/gfx/gl/GL.java.diff?tr1=1.48&tr2=1.49&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/PPDemo.java.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/PPView2.java.diff?tr1=1.67&tr2=1.68&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/demotest.py.diff?tr1=1.74&tr2=1.75&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/modules/pp/vob/BgVob.java.diff?tr1=1.34&tr2=1.35&r1=text&r2=text

Patches:
Index: gzz/gfx/jni/GzzGL-jni.cxx
diff -u gzz/gfx/jni/GzzGL-jni.cxx:1.89 gzz/gfx/jni/GzzGL-jni.cxx:1.90
--- gzz/gfx/jni/GzzGL-jni.cxx:1.89      Mon Feb 24 16:42:34 2003
+++ gzz/gfx/jni/GzzGL-jni.cxx   Mon Mar 17 10:42:18 2003
@@ -1072,6 +1072,7 @@
   }
 
 
+
 #include <sys/time.h>
 double getTime() {
   struct timeval t;
@@ -1174,8 +1175,23 @@
         CurrentFPS::last_time[CurrentFPS::count] = new_time;
 
       }
-       
+
+      CurrentFPS::totalFrames ++;
+  }
+
+
+JNIEXPORT void JNICALL Java_gzz_gfx_gl_GL_clearFrameCountImpl
+  (JNIEnv *env, jclass) {
+      DBG(dbg) << "Clear frame count.\n";
+      CurrentFPS::totalFrames = 0;
+  }
+
+JNIEXPORT jint JNICALL Java_gzz_gfx_gl_GL_getFrameCountImpl
+  (JNIEnv *env, jclass) {
+      DBG(dbg) << "Get frame count.\n";
+      return CurrentFPS::totalFrames;
   }
+
 
 
 JNIEXPORT jfloat JNICALL Java_gzz_gfx_gl_GL_timeRenderImpl
Index: gzz/gfx/librenderables/Renderables.cxx
diff -u gzz/gfx/librenderables/Renderables.cxx:1.17 
gzz/gfx/librenderables/Renderables.cxx:1.18
--- gzz/gfx/librenderables/Renderables.cxx:1.17 Fri Feb 21 15:02:34 2003
+++ gzz/gfx/librenderables/Renderables.cxx      Mon Mar 17 10:42:18 2003
@@ -37,6 +37,9 @@
     double current_fps5;
     double last_time[NCounts];
     int count = 0;
+
+    // total frames  count
+    int totalFrames = 0;
 }
 
 namespace Renderables {
Index: gzz/gfx/librenderables/Renderables.hxx
diff -u gzz/gfx/librenderables/Renderables.hxx:1.32 
gzz/gfx/librenderables/Renderables.hxx:1.33
--- gzz/gfx/librenderables/Renderables.hxx:1.32 Fri Feb 21 15:02:34 2003
+++ gzz/gfx/librenderables/Renderables.hxx      Mon Mar 17 10:42:18 2003
@@ -57,6 +57,9 @@
     extern int count;
     enum { NCounts = 5 };
     extern double last_time[NCounts];
+
+    // Count how many frames is seen between animations
+    extern int totalFrames;
 }
 
 /** The core of Gzz graphics: lists of interpolatable, renderable
Index: gzz/gzz/client/gl/GLUpdateManager.java
diff -u gzz/gzz/client/gl/GLUpdateManager.java:1.14 
gzz/gzz/client/gl/GLUpdateManager.java:1.15
--- gzz/gzz/client/gl/GLUpdateManager.java:1.14 Fri Feb 21 15:02:37 2003
+++ gzz/gzz/client/gl/GLUpdateManager.java      Mon Mar 17 10:42:18 2003
@@ -40,7 +40,7 @@
 
 
 public class GLUpdateManager extends AbstractUpdateManager {
-public static final String rcsid = "$Id: GLUpdateManager.java,v 1.14 
2003/02/21 20:02:37 tjl Exp $";
+public static final String rcsid = "$Id: GLUpdateManager.java,v 1.15 
2003/03/17 15:42:18 mudyc Exp $";
     private static boolean dbg = false;
     private static void p(String s) { if(dbg) pa(s); }
     private static void pa(String s) { System.err.println(s); }
@@ -69,7 +69,9 @@
     /* for demo-events at the end of doIdle() */
     private ActionListener actionListener = null;
     public synchronized void addActionListener(ActionListener l) {
-        actionListener = AWTEventMulticaster.add(actionListener, l);
+       if (actionListener != null) 
+           actionListener = AWTEventMulticaster.remove(actionListener, 
actionListener);
+       actionListener = AWTEventMulticaster.add(actionListener, l);
     }
     private void processEvent(ActionEvent e) {
         if (actionListener != null) {
Index: gzz/gzz/gfx/gl/GL.java
diff -u gzz/gzz/gfx/gl/GL.java:1.48 gzz/gzz/gfx/gl/GL.java:1.49
--- gzz/gzz/gfx/gl/GL.java:1.48 Fri Feb 21 15:02:38 2003
+++ gzz/gzz/gfx/gl/GL.java      Mon Mar 17 10:42:18 2003
@@ -844,6 +844,16 @@
                    float fract, boolean standardcoords,
                boolean showFinal);
 
+    // Frame Counts 
+    public static void clearFrameCount() { 
+       clearFrameCountImpl();
+    } private static native void clearFrameCountImpl();
+
+    public static int getFrameCount() { 
+       return getFrameCountImpl();
+    } private static native int getFrameCountImpl();
+
+
     public static float timeRender(
                    RenderingSurface win, int iters,
                    int ninds, int[] inds1, float[] pts1, 
Index: gzz/gzz/modules/pp/PPDemo.java
diff -u gzz/gzz/modules/pp/PPDemo.java:1.4 gzz/gzz/modules/pp/PPDemo.java:1.5
--- gzz/gzz/modules/pp/PPDemo.java:1.4  Fri Feb 21 15:02:43 2003
+++ gzz/gzz/modules/pp/PPDemo.java      Mon Mar 17 10:42:19 2003
@@ -43,16 +43,32 @@
  * So let's talk about it like demo or robustness test.
  */
 public class PPDemo implements ActionListener {
-    public static final String rcsid = "$Id: PPDemo.java,v 1.4 2003/02/21 
20:02:43 tjl Exp $";
+    public static final String rcsid = "$Id: PPDemo.java,v 1.5 2003/03/17 
15:42:19 mudyc Exp $";
     private static boolean dbg = false;
     private void pa(String s) { System.out.println(s); }
 
     private PPView2 ppv;
     private AbstractViewContext avc;
+    private int rand;
+    static private int maxCount = 0;
+    private PPDemo.Hook hook;
+
     public PPDemo(PPView2 p, GLUpdateManager g, AbstractViewContext a) {
+       this(p,g, a, -1, -1, null);
+    }
+    public PPDemo(PPView2 p, GLUpdateManager g, AbstractViewContext a, 
+                 int rand, int count, PPDemo.Hook hook) {
         this.ppv = p;
         this.avc = a;
         g.addActionListener(this);
+       this.rand = rand;
+       if (this.maxCount == 0) 
+           this.maxCount = count;
+       this.hook = hook;
+    }
+
+    public interface Hook {
+       public void nextRound();
     }
 
 
@@ -61,15 +77,26 @@
     public void actionPerformed(ActionEvent e) {
         if (dbg) pa("Event "+e);
 
+       if (maxCount > 0) maxCount--;
+       if (maxCount == 0)  { 
+           hook.nextRound();
+           return;
+       }
+       
+
         PPDims d = ppv.d;
         Cell c = avc.getAccursed();
         
         if (dbg) pa("In Cell: "+c);
         start = c.h(d.clone);
 
-        Random r = new Random();
+       Random r;
+       if (rand > 0 ) 
+           r = new Random(rand);
+       else 
+           r = new Random();
         int rand = r.nextInt(100);
-        
+    
         // if just cam to paper - jump to different note
         if (justCameToPaper) {
             ppv.clearInterps();
@@ -149,7 +176,11 @@
         // we don't want to go to the paper..
         if ( dir < 0) jumps--;
 
-        Random r = new Random();
+       Random r;
+       if (rand > 0 ) 
+           r = new Random(rand);
+       else 
+           r = new Random();
         int go = 1 + r.nextInt(jumps-1);
 
         c = avc.getAccursed();
Index: gzz/gzz/modules/pp/PPView2.java
diff -u gzz/gzz/modules/pp/PPView2.java:1.67 
gzz/gzz/modules/pp/PPView2.java:1.68
--- gzz/gzz/modules/pp/PPView2.java:1.67        Fri Feb 21 15:02:43 2003
+++ gzz/gzz/modules/pp/PPView2.java     Mon Mar 17 10:42:19 2003
@@ -41,10 +41,22 @@
 import java.util.*;
 
 public class PPView2 implements View {
-public static final String rcsid = "$Id: PPView2.java,v 1.67 2003/02/21 
20:02:43 tjl Exp $";
+public static final String rcsid = "$Id: PPView2.java,v 1.68 2003/03/17 
15:42:19 mudyc Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
+
+    // Benchmarks
+    static public final int BM_irregu = 0;
+    static public final int BM_paper = 1;
+    static public final int BM_shortcuts = 2;
+    static public final int BM_text = 3;
+    static public final int BM_bg = 4;
+    static public final int BM_fillet = 5;
+    static public boolean[] benchmarks = 
+    { true,true,true,true,true,true};
+
+
     public static Object NEWPAPERKEY = new Object();
 
     /** Modes */
@@ -265,6 +277,7 @@
                            // vs.map.put(bg, frameUnit, bg2screen);
                            bg.put(vs, frameUnit, bg2screen);
                            vs.map.put(black);
+                           if (PPView2.benchmarks[PPView2.BM_text])
                            coordinatePlaneView.render(vs, 
paper2screen_shifted, context, frameCS);
                        }};
 
@@ -368,7 +381,8 @@
                    vs.map.put(filletState);
                    int curs = coordinatePlaneView.getCursorBox();
                    if (dbg) pa("Fillet curs: "+curs);
-                   vs.map.put(fillet, anchorUnit, vs.unitSqCS(curs, "AUSQ"));
+                   if (PPView2.benchmarks[PPView2.BM_fillet])
+                       vs.map.put(fillet, anchorUnit, vs.unitSqCS(curs, 
"AUSQ"));
                    vs.map.put(postFilletState);
                }
            });
@@ -502,7 +516,7 @@
                    plane = plane.s(d.d1);
                }
            }
-       } else {
+       } else if (PPView2.benchmarks[PPView2.BM_shortcuts]) {
            // the left panel (shortcuts)
            // ==========================
 
Index: gzz/gzz/modules/pp/demotest.py
diff -u gzz/gzz/modules/pp/demotest.py:1.74 gzz/gzz/modules/pp/demotest.py:1.75
--- gzz/gzz/modules/pp/demotest.py:1.74 Fri Feb 21 15:02:43 2003
+++ gzz/gzz/modules/pp/demotest.py      Mon Mar 17 10:42:19 2003
@@ -55,7 +55,7 @@
 slicer = SingleSlicer("foo")
 
 usingNormalBindings = 0
-ownUse = 1
+ownUse = 0
 
 if ownUse:
     PPDIR=os.getcwd()+'/pp/'
@@ -172,6 +172,11 @@
         elif key == "Ctrl-Q":
             clean_data('except_pkg')
             System.exit(43)
+        elif key == "Ctrl-B":
+            print '*Benchmark*'
+            d = DoBenchMark(self.ppv, self.vs, self.avc,
+                            
self.space.getHomeCell().s(self.d.d1).s(self.d.contains))
+            d.run()
        elif key == "Ctrl-I":
            print "INTERPLIST"
            self.vs.dump()
@@ -318,8 +323,6 @@
                     else:
                         print '...what\'s then?'
                         self.ppactions.insertText(c.getId(), 0, '_')
-                        
-                    
             if key == "Delete":
                 print 'Untested! Doesn\'t check the length'
                 self.ppactions.deleteText(c.getId(), offs, offs+1)
@@ -334,10 +337,9 @@
             vs.map.put(background((0.6,0.7,0.9)))
         elif m == self.ppv.LINK_KILLING:
             vs.map.put(background((0.8,0.4,0.7)))
-            
-       vs.map.put(getDListNocoords("""
-           PolygonMode FRONT_AND_BACK %s
-       """ % (self.poly[0],)))
+        vs.map.put(getDListNocoords("""
+            PolygonMode FRONT_AND_BACK %s
+        """ % (self.poly[0],)))
        self.ppv.render(vs, 0, self.avc)
        self.vs = vs
 
@@ -372,13 +374,69 @@
 
 
 
-currentScene = PPView2Scene()
 
 
 
+class DoBenchMark(PPDemo.Hook):
+    def __init__(self, pp, vs, avc, home):
+        self.pp = pp
+        self.vs = vs
+        self.avc = avc
+        self.iter = -1
+        self.home = home
+
+        a = self.pp
+        self.benchmarks = a.benchmarks
+        self.explanation = [ 'irregu', 'paper', 'shortcuts', 
+                             'text', 'background', 'fillet', 'nothing' ]
+
+        self.animTime = AbstractUpdateManager.defaultAnimationTime
+        AbstractUpdateManager.defaultAnimationTime = 3000
+
+    def run(self):
+        # First empty run
+        if self.iter < 0:
+            self.trueList()
+            self.doBench()
+
+        elif self.iter >= 0 and self.iter < len(self.benchmarks):
+            self.trueList()
+            self.benchmarks[self.iter] = 0
+            self.doBench()
 
+        else:
+            self.trueList()
+            self.doBench()
 
+    def trueList(self):
+        for i in range(len(self.benchmarks)):
+            self.benchmarks[i] = 1
+    def doBench(self):
+        a = gzz.client.gl.GLUpdateManager
+        gzz.gfx.gl.GL.clearFrameCount()
+        self.avc.setAccursed(self.home)
+        AbstractUpdateManager.setNoAnimation()
+        AbstractUpdateManager.chg()
+
+        self.demo = PPDemo(self.pp, a.getInstance(), self.avc, 765, 5, self)
+        a.demoMode = 1
+
+    # implement Hook
+    def nextRound(self):
+        # say previous
+        print self.iter,': Benchmark - leave out', 
self.explanation[self.iter],': ',\
+              gzz.gfx.gl.GL.getFrameCount(), ' frames.'
+        self.iter += 1
 
+        if self.iter <= len(self.benchmarks): # notice add..
+            self.run()
+        else:
+            AbstractUpdateManager.defaultAnimationTime = self.animTime
+            a = gzz.client.gl.GLUpdateManager
+            a.demoMode = 0
+            return
+
+currentScene = PPView2Scene()
 
 
 
Index: gzz/gzz/modules/pp/vob/BgVob.java
diff -u gzz/gzz/modules/pp/vob/BgVob.java:1.34 
gzz/gzz/modules/pp/vob/BgVob.java:1.35
--- gzz/gzz/modules/pp/vob/BgVob.java:1.34      Fri Feb 21 15:02:43 2003
+++ gzz/gzz/modules/pp/vob/BgVob.java   Mon Mar 17 10:42:19 2003
@@ -42,7 +42,7 @@
  * used to pan pretty easily.
  */
 public class BgVob extends gzz.vob.Vob {
-public static final String rcsid = "$Id: BgVob.java,v 1.34 2003/02/21 20:02:43 
tjl Exp $";
+public static final String rcsid = "$Id: BgVob.java,v 1.35 2003/03/17 15:42:19 
mudyc Exp $";
     public static boolean dbg = false;
     private static void pa(String s) { System.err.println(s); }
 
@@ -106,17 +106,19 @@
     }
 
     public void put(VobScene vs, int cs1, int cs2) {
+       if (gzz.modules.pp.PPView2.benchmarks[gzz.modules.pp.PPView2.BM_paper])
        vs.map.put(this, cs1, cs2);
        if(dbg) pa("BgVob.put: "+papercode+" "+other);
-       if(other != null) {
-           // other.put(vs, cs1);
-           other.put(vs, cs2);
+       if(other != null ) {    
+           if (gzz.modules.pp.PPView2.benchmarks[gzz.modules.pp.PPView2.BM_bg])
+               // other.put(vs, cs1);
+               other.put(vs, cs2);
        }
     }
 
      public int putGL(VobScene vs, int coordsys1, int coordsys2) {
-       vs.map.put(pq, coordsys1, coordsys2);
-       return 0;
+        vs.map.put(pq, coordsys1, coordsys2);
+        return 0;
     }
     
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]