Demos (master): Always flush stdout after writing FPS.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Fri Oct 14 11:55:49 PDT 2011


Module: Demos
Branch: master
Commit: 448fd18501ad5a8357aee72bdeada9951ca3a849
URL:    http://cgit.freedesktop.org/mesa/demos/commit/?id=448fd18501ad5a8357aee72bdeada9951ca3a849

Author: José Fonseca <jfonseca at vmware.com>
Date:   Fri Oct 14 19:54:19 2011 +0100

Always flush stdout after writing FPS.

Otherwise scripts that read stdout would need to wait for a long time
before anything appears through the pipe.

---

 src/demos/ipers.c              |    1 +
 src/egl/eglut/eglut_screen.c   |    1 +
 src/egl/opengl/peglgears.c     |    1 +
 src/objviewer/objview.c        |    4 +++-
 src/vp/vp-tris.c               |    1 +
 src/xdemos/glxcontexts.c       |    1 +
 src/xdemos/glxgears.c          |    1 +
 src/xdemos/glxgears_fbconfig.c |    1 +
 src/xdemos/glxgears_pixmap.c   |    1 +
 src/xdemos/glxswapcontrol.c    |    1 +
 10 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/demos/ipers.c b/src/demos/ipers.c
index e95431e..4ecf7cc 100644
--- a/src/demos/ipers.c
+++ b/src/demos/ipers.c
@@ -672,6 +672,7 @@ draw(void)
          GLfloat seconds = (t - T0) / 1000.0;
          fr = Frames / seconds;
          printf("Frame rate: %f\n", fr);
+         fflush(stdout);
          T0 = t;
          Frames = 0;
       }
diff --git a/src/egl/eglut/eglut_screen.c b/src/egl/eglut/eglut_screen.c
index 4e8bff3..021a8f1 100644
--- a/src/egl/eglut/eglut_screen.c
+++ b/src/egl/eglut/eglut_screen.c
@@ -155,6 +155,7 @@ _eglutNativeEventLoop(void)
 
          printf("%d frames in %3.1f seconds = %6.3f FPS\n",
                frames, elapsed, frames / elapsed);
+         fflush(stdout);
 
          start = now;
          frames = 0;
diff --git a/src/egl/opengl/peglgears.c b/src/egl/opengl/peglgears.c
index e393115..438287b 100644
--- a/src/egl/opengl/peglgears.c
+++ b/src/egl/opengl/peglgears.c
@@ -357,6 +357,7 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr)
 	seconds = ct - st;
 	fps = frames / seconds;
 	printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps);
+	fflush(stdout);
 	
 }
 
diff --git a/src/objviewer/objview.c b/src/objviewer/objview.c
index 64c4a9f..6def726 100644
--- a/src/objviewer/objview.c
+++ b/src/objviewer/objview.c
@@ -284,8 +284,10 @@ display(void)
    glutSwapBuffers();
 
    fps = ComputeFPS();
-   if (fps)
+   if (fps) {
       printf("%f FPS\n", fps);
+      fflush(stdout);
+   }
 }
 
 
diff --git a/src/vp/vp-tris.c b/src/vp/vp-tris.c
index d064535..8840a8f 100644
--- a/src/vp/vp-tris.c
+++ b/src/vp/vp-tris.c
@@ -43,6 +43,7 @@ void alarmhandler (int sig)
    if (sig == SIGALRM) {
       printf("%d frames in 5.0 seconds = %.3f FPS\n", frame_cnt,
              frame_cnt / 5.0);
+      fflush(stdout);
 
       frame_cnt = 0;
    }
diff --git a/src/xdemos/glxcontexts.c b/src/xdemos/glxcontexts.c
index 9f83679..3467e3c 100644
--- a/src/xdemos/glxcontexts.c
+++ b/src/xdemos/glxcontexts.c
@@ -490,6 +490,7 @@ event_loop(Display *dpy)
             GLfloat fps = frames / seconds;
             printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
                    fps);
+	    fflush(stdout);
             tRate0 = t;
 
             /* Destroy window and create new one */	    
diff --git a/src/xdemos/glxgears.c b/src/xdemos/glxgears.c
index 92c75ca..cff92b0 100644
--- a/src/xdemos/glxgears.c
+++ b/src/xdemos/glxgears.c
@@ -349,6 +349,7 @@ draw_frame(Display *dpy, Window win)
       GLfloat fps = frames / seconds;
       printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
              fps);
+      fflush(stdout);
       tRate0 = t;
       frames = 0;
    }
diff --git a/src/xdemos/glxgears_fbconfig.c b/src/xdemos/glxgears_fbconfig.c
index 36bf731..cffef28 100644
--- a/src/xdemos/glxgears_fbconfig.c
+++ b/src/xdemos/glxgears_fbconfig.c
@@ -573,6 +573,7 @@ event_loop(Display *dpy, GLXWindow win)
             GLfloat fps = frames / seconds;
             printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
                    fps);
+            fflush(stdout);
             t0 = t;
             frames = 0;
          }
diff --git a/src/xdemos/glxgears_pixmap.c b/src/xdemos/glxgears_pixmap.c
index 661d130..4b9e55a 100644
--- a/src/xdemos/glxgears_pixmap.c
+++ b/src/xdemos/glxgears_pixmap.c
@@ -489,6 +489,7 @@ event_loop(Display *dpy, struct gears *gears)
             GLfloat fps = frames / seconds;
             printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
                    fps);
+            fflush(stdout);
             t0 = t;
             frames = 0;
          }
diff --git a/src/xdemos/glxswapcontrol.c b/src/xdemos/glxswapcontrol.c
index 7c4b413..59a3e80 100644
--- a/src/xdemos/glxswapcontrol.c
+++ b/src/xdemos/glxswapcontrol.c
@@ -620,6 +620,7 @@ event_loop(Display *dpy, Window win)
 	       printf("%d frames in %3.1f seconds = %6.3f FPS\n",
 		      frames, seconds, fps);
 	    }
+	    fflush(stdout);
 
             t0 = t;
             frames = 0;



More information about the mesa-commit mailing list