freetype-commit
[Top][All Lists]
Advanced

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

[freetype2] gsoc-2023-ahmet-final dcfebc9a0 5/6: [ftbench] only one time


From: Werner Lemberg
Subject: [freetype2] gsoc-2023-ahmet-final dcfebc9a0 5/6: [ftbench] only one timer in use
Date: Thu, 21 Sep 2023 20:27:43 -0400 (EDT)

branch: gsoc-2023-ahmet-final
commit dcfebc9a0763f1633747310ce0c0537b131c140a
Author: goksu <25721443+goeksu@users.noreply.github.com>
Commit: goksu <25721443+goeksu@users.noreply.github.com>

    [ftbench] only one timer in use
    
    Now, cleared 'elapsed' timer. All time measurement is done in the 
benchmark() function. Created a timer inside of main() function to show total 
spent time.
---
 src/tools/ftbench/ftbench.c | 149 ++++++++++++++------------------------------
 1 file changed, 46 insertions(+), 103 deletions(-)

diff --git a/src/tools/ftbench/ftbench.c b/src/tools/ftbench/ftbench.c
index 6d4a40ab3..3522043d3 100644
--- a/src/tools/ftbench/ftbench.c
+++ b/src/tools/ftbench/ftbench.c
@@ -66,8 +66,7 @@
 
 
   typedef int
-  (*bcall_t)( btimer_t*  timer,
-              FT_Face    face,
+  (*bcall_t)( FT_Face    face,
               void*      user_data );
 
 
@@ -273,35 +272,34 @@
              double    warmup )
   {
     int       n, done;
-    btimer_t  timer, elapsed;
+    btimer_t  timer;
 
 
     if ( test->cache_first )
     {
       TIMER_RESET( &timer );
-      test->bench( &timer, face, test->user_data );
+      test->bench( face, test->user_data );
     }
 
-    TIMER_START(&elapsed);
+    TIMER_START(&timer);
     for(int i = 0; i<warmup; i++)
-        test->bench( &timer,face, test->user_data);
-    TIMER_STOP(&elapsed);
+        test->bench(face, test->user_data);
+    TIMER_STOP(&timer);
 
     printf( "  %-25s ", test->title );
     fflush( stdout );
 
     TIMER_RESET( &timer );
-    TIMER_RESET( &elapsed );
 
     for ( n = 0, done = 0; !max_iter || n < max_iter; n++ )
     {
-      TIMER_START( &elapsed );
+      TIMER_START( &timer );
 
-      done += test->bench( &timer, face, test->user_data );
+      done += test->bench( face, test->user_data );
 
-      TIMER_STOP( &elapsed );
+      TIMER_STOP( &timer );
 
-      if ( TIMER_GET( &elapsed ) > 1E6 * max_time )
+      if ( TIMER_GET( &timer ) > 1E6 * max_time )
         break;
     }
 
@@ -318,8 +316,7 @@
    */
 
   static int
-  test_load( btimer_t*  timer,
-             FT_Face    face,
+  test_load( FT_Face    face,
              void*      user_data )
   {
     int  i, done = 0;
@@ -327,23 +324,18 @@
     FT_UNUSED( user_data );
 
 
-    TIMER_START( timer );
-
     FOREACH( i )
     {
       if ( !FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
         done++;
     }
 
-    TIMER_STOP( timer );
-
     return done;
   }
 
 
   static int
-  test_load_advances( btimer_t*  timer,
-                      FT_Face    face,
+  test_load_advances( FT_Face    face,
                       void*      user_data )
   {
     int        done = 0;
@@ -365,15 +357,11 @@
 
     advances = (FT_Fixed *)calloc( sizeof ( FT_Fixed ), (size_t)count );
 
-    TIMER_START( timer );
-
     FT_Get_Advances( face,
                      (FT_UInt)start, (FT_UInt)count,
                      (FT_Int32)flags, advances );
     done += (int)count;
 
-    TIMER_STOP( timer );
-
     free( advances );
 
     return done;
@@ -381,8 +369,7 @@
 
 
   static int
-  test_render( btimer_t*  timer,
-               FT_Face    face,
+  test_render( FT_Face    face,
                void*      user_data )
   {
     int  i, done = 0;
@@ -395,19 +382,16 @@
       if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
         continue;
 
-      TIMER_START( timer );
-      if ( !FT_Render_Glyph( face->glyph, render_mode ) )
+            if ( !FT_Render_Glyph( face->glyph, render_mode ) )
         done++;
-      TIMER_STOP( timer );
-    }
+          }
 
     return done;
   }
 
 
   static int
-  test_embolden( btimer_t*  timer,
-                 FT_Face    face,
+  test_embolden( FT_Face    face,
                  void*      user_data )
   {
     int  i, done = 0;
@@ -420,19 +404,16 @@
       if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
         continue;
 
-      TIMER_START( timer );
-      FT_GlyphSlot_Embolden( face->glyph );
+            FT_GlyphSlot_Embolden( face->glyph );
       done++;
-      TIMER_STOP( timer );
-    }
+          }
 
     return done;
   }
 
 
   static int
-  test_stroke( btimer_t*  timer,
-               FT_Face    face,
+  test_stroke( FT_Face    face,
                void*      user_data )
   {
     FT_Glyph    glyph;
@@ -456,9 +437,7 @@
            FT_Get_Glyph( face->glyph, &glyph )            )
         continue;
 
-      TIMER_START( timer );
-      FT_Glyph_Stroke( &glyph, stroker, 1 );
-      TIMER_STOP( timer );
+            FT_Glyph_Stroke( &glyph, stroker, 1 );
 
       FT_Done_Glyph( glyph );
       done++;
@@ -471,8 +450,7 @@
 
 
   static int
-  test_get_glyph( btimer_t*  timer,
-                  FT_Face    face,
+  test_get_glyph( FT_Face    face,
                   void*      user_data )
   {
     FT_Glyph  glyph;
@@ -487,22 +465,19 @@
       if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
         continue;
 
-      TIMER_START( timer );
-      if ( !FT_Get_Glyph( face->glyph, &glyph ) )
+            if ( !FT_Get_Glyph( face->glyph, &glyph ) )
       {
         FT_Done_Glyph( glyph );
         done++;
       }
-      TIMER_STOP( timer );
-    }
+          }
 
     return done;
   }
 
 
   static int
-  test_get_cbox( btimer_t*  timer,
-                 FT_Face    face,
+  test_get_cbox( FT_Face    face,
                  void*      user_data )
   {
     FT_Glyph  glyph;
@@ -521,9 +496,7 @@
       if ( FT_Get_Glyph( face->glyph, &glyph ) )
         continue;
 
-      TIMER_START( timer );
-      FT_Glyph_Get_CBox( glyph, FT_GLYPH_BBOX_PIXELS, &bbox );
-      TIMER_STOP( timer );
+            FT_Glyph_Get_CBox( glyph, FT_GLYPH_BBOX_PIXELS, &bbox );
 
       FT_Done_Glyph( glyph );
       done++;
@@ -534,8 +507,7 @@
 
 
   static int
-  test_get_bbox( btimer_t*  timer,
-                 FT_Face    face,
+  test_get_bbox( FT_Face    face,
                  void*      user_data )
   {
     FT_BBox    bbox;
@@ -550,9 +522,7 @@
       if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
         continue;
 
-      TIMER_START( timer );
-      FT_Outline_Get_BBox( &face->glyph->outline, &bbox );
-      TIMER_STOP( timer );
+            FT_Outline_Get_BBox( &face->glyph->outline, &bbox );
 
       done++;
     }
@@ -562,31 +532,25 @@
 
 
   static int
-  test_get_char_index( btimer_t*  timer,
-                       FT_Face    face,
+  test_get_char_index( FT_Face    face,
                        void*      user_data )
   {
     bcharset_t*  charset = (bcharset_t*)user_data;
     int          i, done = 0;
 
 
-    TIMER_START( timer );
-
     for ( i = 0; i < charset->size; i++ )
     {
       if ( FT_Get_Char_Index(face, charset->code[i]) )
         done++;
     }
 
-    TIMER_STOP( timer );
-
     return done;
   }
 
 
   static int
-  test_cmap_cache( btimer_t*  timer,
-                   FT_Face    face,
+  test_cmap_cache( FT_Face    face,
                    void*      user_data )
   {
     bcharset_t*  charset = (bcharset_t*)user_data;
@@ -595,8 +559,6 @@
     FT_UNUSED( face );
 
 
-    TIMER_START( timer );
-
     for ( i = 0; i < charset->size; i++ )
     {
       if ( FTC_CMapCache_Lookup( cmap_cache,
@@ -606,15 +568,12 @@
         done++;
     }
 
-    TIMER_STOP( timer );
-
     return done;
   }
 
 
   static int
-  test_image_cache( btimer_t*  timer,
-                    FT_Face    face,
+  test_image_cache( FT_Face    face,
                     void*      user_data )
   {
     FT_Glyph  glyph;
@@ -624,9 +583,6 @@
     FT_UNUSED( face );
     FT_UNUSED( user_data );
 
-
-    TIMER_START( timer );
-
     FOREACH( i )
     {
       if ( !FTC_ImageCache_Lookup( image_cache,
@@ -637,15 +593,12 @@
         done++;
     }
 
-    TIMER_STOP( timer );
-
     return done;
   }
 
 
   static int
-  test_sbit_cache( btimer_t*  timer,
-                   FT_Face    face,
+  test_sbit_cache( FT_Face    face,
                    void*      user_data )
   {
     FTC_SBit  glyph;
@@ -655,9 +608,6 @@
     FT_UNUSED( face );
     FT_UNUSED( user_data );
 
-
-    TIMER_START( timer );
-
     FOREACH( i )
     {
       if ( !FTC_SBitCache_Lookup( sbit_cache,
@@ -668,15 +618,12 @@
         done++;
     }
 
-    TIMER_STOP( timer );
-
     return done;
   }
 
 
   static int
-  test_cmap_iter( btimer_t*  timer,
-                  FT_Face    face,
+  test_cmap_iter( FT_Face    face,
                   void*      user_data )
   {
     FT_UInt   idx;
@@ -686,23 +633,18 @@
     FT_UNUSED( user_data );
 
 
-    TIMER_START( timer );
-
     charcode = FT_Get_First_Char( face, &idx );
     done = ( idx != 0 );
 
     while ( idx != 0 )
       charcode = FT_Get_Next_Char( face, charcode, &idx );
 
-    TIMER_STOP( timer );
-
-    return done;
+        return done;
   }
 
 
   static int
-  test_new_face( btimer_t*  timer,
-                 FT_Face    face,
+  test_new_face( FT_Face    face,
                  void*      user_data )
   {
     FT_Face  bench_face;
@@ -711,20 +653,15 @@
     FT_UNUSED( user_data );
 
 
-    TIMER_START( timer );
-
     if ( !get_face( &bench_face ) )
       FT_Done_Face( bench_face );
 
-    TIMER_STOP( timer );
-
-    return 1;
+        return 1;
   }
 
 
   static int
-  test_new_face_and_load_glyph( btimer_t*  timer,
-                                FT_Face    face,
+  test_new_face_and_load_glyph( FT_Face    face,
                                 void*      user_data )
   {
     FT_Face  bench_face;
@@ -735,8 +672,6 @@
     FT_UNUSED( user_data );
 
 
-    TIMER_START( timer );
-
     if ( !get_face( &bench_face ) )
     {
       FOREACH( i )
@@ -748,8 +683,6 @@
       FT_Done_Face( bench_face );
     }
 
-    TIMER_STOP( timer );
-
     return done;
   }
 
@@ -1103,6 +1036,10 @@
   {
     FT_Face   face;
     FT_Error  error;
+    btimer_t total;
+
+    TIMER_RESET(&total);
+    TIMER_START(&total);
 
     unsigned long  max_bytes      = CACHE_SIZE * 1024;
     char*          test_string    = NULL;
@@ -1356,6 +1293,9 @@
         if ( warmup_iter < 0 )
           warmup_iter = -warmup_iter;
         break;
+
+
+
         /* break; */
 
       default:
@@ -1616,6 +1556,9 @@
         break;
       }
     }
+    TIMER_STOP(&total);
+    double total_time = TIMER_GET(&total);
+    printf("\nTotal time: %.0fs\n", total_time/1000000);
 
     if ( cache_man )
       FTC_Manager_Done( cache_man );



reply via email to

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