]> git.cworth.org Git - fips/commitdiff
fips: Add a -v/--verbose flag.
authorCarl Worth <cworth@cworth.org>
Thu, 27 Jun 2013 20:23:55 +0000 (13:23 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 27 Jun 2013 20:23:55 +0000 (13:23 -0700)
The only real purpose imagined for this for now is to be able to
verify that fips is actually doing something, (for example, if a
program renders less than 60 frames and exits then previous fips would
exit silently).

The --verbose flag will be useful with the upcoming test suite and its
short-lived programs.

fips.c
metrics.c

diff --git a/fips.c b/fips.c
index fca2da8ec7c6e6df1c9d199e8e3f5b470d088548..5aeb8c3f10740ce97313d7a9ea38de926999477a 100644 (file)
--- a/fips.c
+++ b/fips.c
@@ -35,6 +35,7 @@ usage (void)
               "\n"
               "Options:\n"
               "        -h, --help      show this help message\n"
+              "        -v, --verbose   print verbose messages about fips activity"
               "\n");
 }
 
@@ -53,9 +54,10 @@ main (int argc, char *argv[])
         * "glxgears -fullscreen" rather than trying to interpret
         * -fullscreen as options to fips itself.
         */
-       const char *short_options = "+h";
+       const char *short_options = "+hv";
        const struct option long_options[] = {
                {"help", no_argument, 0, 'h'},
+               {"verbose", no_argument, 0, 'v'},
                {0, 0, 0, 0}
        };
 
@@ -69,6 +71,9 @@ main (int argc, char *argv[])
                case 'h':
                        usage ();
                        return 0;
+               case 'v':
+                       setenv ("FIPS_VERBOSE", "1", 1);
+                       break;
                case '?':
                        break;
                default:
index 84fc23f6b20b02a2a15ece51ee9b63447d4e5466..39ed5bacf2f9733010b5564893e76b9f7b0be1a1 100644 (file)
--- a/metrics.c
+++ b/metrics.c
@@ -57,6 +57,9 @@ typedef struct context
 
 context_t current_context;
 
+int frames;
+int verbose;
+
 unsigned
 metrics_counter_new (void)
 {
@@ -137,19 +140,31 @@ print_program_metrics (void)
        }
 }
 
+/* Called at program exit */
+static void
+metrics_exit (void)
+{
+       if (verbose)
+               printf ("fips: terminating\n");
+}
+
+
 void
 metrics_end_frame (void)
 {
        static int initialized = 0;
-       static int frames;
        static struct timeval tv_start, tv_now;
 
        if (! initialized) {
-               frames = 0;
                gettimeofday (&tv_start, NULL);
+               atexit (metrics_exit);
+               if (getenv ("FIPS_VERBOSE"))
+                       verbose = 1;
                initialized = 1;
        }
 
+       if (verbose)
+               printf ("fips: frame %d complete\n", frames);
 
        frames++;
        gettimeofday (&tv_now, NULL);