freetype-commit
[Top][All Lists]
Advanced

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

[Git][freetype/freetype][gsoc-2023-ahmet-final] [ftbench] only one timer


From: @goksu
Subject: [Git][freetype/freetype][gsoc-2023-ahmet-final] [ftbench] only one timer in use
Date: Thu, 21 Sep 2023 12:15:04 +0000

Ahmet Göksu pushed to branch gsoc-2023-ahmet-final at FreeType / FreeType

Commits:

  • dcfebc9a
    by goksu at 2023-09-21T15:14:41+03:00
    [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.
    

1 changed file:

Changes:

  • src/tools/ftbench/ftbench.c
    ... ... @@ -66,8 +66,7 @@
    66 66
     
    
    67 67
     
    
    68 68
       typedef int
    
    69
    -  (*bcall_t)( btimer_t*  timer,
    
    70
    -              FT_Face    face,
    
    69
    +  (*bcall_t)( FT_Face    face,
    
    71 70
                   void*      user_data );
    
    72 71
     
    
    73 72
     
    
    ... ... @@ -273,35 +272,34 @@
    273 272
                  double    warmup )
    
    274 273
       {
    
    275 274
         int       n, done;
    
    276
    -    btimer_t  timer, elapsed;
    
    275
    +    btimer_t  timer;
    
    277 276
     
    
    278 277
     
    
    279 278
         if ( test->cache_first )
    
    280 279
         {
    
    281 280
           TIMER_RESET( &timer );
    
    282
    -      test->bench( &timer, face, test->user_data );
    
    281
    +      test->bench( face, test->user_data );
    
    283 282
         }
    
    284 283
     
    
    285
    -    TIMER_START(&elapsed);
    
    284
    +    TIMER_START(&timer);
    
    286 285
         for(int i = 0; i<warmup; i++)
    
    287
    -        test->bench( &timer,face, test->user_data);
    
    288
    -    TIMER_STOP(&elapsed);
    
    286
    +        test->bench(face, test->user_data);
    
    287
    +    TIMER_STOP(&timer);
    
    289 288
     
    
    290 289
         printf( "  %-25s ", test->title );
    
    291 290
         fflush( stdout );
    
    292 291
     
    
    293 292
         TIMER_RESET( &timer );
    
    294
    -    TIMER_RESET( &elapsed );
    
    295 293
     
    
    296 294
         for ( n = 0, done = 0; !max_iter || n < max_iter; n++ )
    
    297 295
         {
    
    298
    -      TIMER_START( &elapsed );
    
    296
    +      TIMER_START( &timer );
    
    299 297
     
    
    300
    -      done += test->bench( &timer, face, test->user_data );
    
    298
    +      done += test->bench( face, test->user_data );
    
    301 299
     
    
    302
    -      TIMER_STOP( &elapsed );
    
    300
    +      TIMER_STOP( &timer );
    
    303 301
     
    
    304
    -      if ( TIMER_GET( &elapsed ) > 1E6 * max_time )
    
    302
    +      if ( TIMER_GET( &timer ) > 1E6 * max_time )
    
    305 303
             break;
    
    306 304
         }
    
    307 305
     
    
    ... ... @@ -318,8 +316,7 @@
    318 316
        */
    
    319 317
     
    
    320 318
       static int
    
    321
    -  test_load( btimer_t*  timer,
    
    322
    -             FT_Face    face,
    
    319
    +  test_load( FT_Face    face,
    
    323 320
                  void*      user_data )
    
    324 321
       {
    
    325 322
         int  i, done = 0;
    
    ... ... @@ -327,23 +324,18 @@
    327 324
         FT_UNUSED( user_data );
    
    328 325
     
    
    329 326
     
    
    330
    -    TIMER_START( timer );
    
    331
    -
    
    332 327
         FOREACH( i )
    
    333 328
         {
    
    334 329
           if ( !FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
    
    335 330
             done++;
    
    336 331
         }
    
    337 332
     
    
    338
    -    TIMER_STOP( timer );
    
    339
    -
    
    340 333
         return done;
    
    341 334
       }
    
    342 335
     
    
    343 336
     
    
    344 337
       static int
    
    345
    -  test_load_advances( btimer_t*  timer,
    
    346
    -                      FT_Face    face,
    
    338
    +  test_load_advances( FT_Face    face,
    
    347 339
                           void*      user_data )
    
    348 340
       {
    
    349 341
         int        done = 0;
    
    ... ... @@ -365,15 +357,11 @@
    365 357
     
    
    366 358
         advances = (FT_Fixed *)calloc( sizeof ( FT_Fixed ), (size_t)count );
    
    367 359
     
    
    368
    -    TIMER_START( timer );
    
    369
    -
    
    370 360
         FT_Get_Advances( face,
    
    371 361
                          (FT_UInt)start, (FT_UInt)count,
    
    372 362
                          (FT_Int32)flags, advances );
    
    373 363
         done += (int)count;
    
    374 364
     
    
    375
    -    TIMER_STOP( timer );
    
    376
    -
    
    377 365
         free( advances );
    
    378 366
     
    
    379 367
         return done;
    
    ... ... @@ -381,8 +369,7 @@
    381 369
     
    
    382 370
     
    
    383 371
       static int
    
    384
    -  test_render( btimer_t*  timer,
    
    385
    -               FT_Face    face,
    
    372
    +  test_render( FT_Face    face,
    
    386 373
                    void*      user_data )
    
    387 374
       {
    
    388 375
         int  i, done = 0;
    
    ... ... @@ -395,19 +382,16 @@
    395 382
           if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
    
    396 383
             continue;
    
    397 384
     
    
    398
    -      TIMER_START( timer );
    
    399
    -      if ( !FT_Render_Glyph( face->glyph, render_mode ) )
    
    385
    +            if ( !FT_Render_Glyph( face->glyph, render_mode ) )
    
    400 386
             done++;
    
    401
    -      TIMER_STOP( timer );
    
    402
    -    }
    
    387
    +          }
    
    403 388
     
    
    404 389
         return done;
    
    405 390
       }
    
    406 391
     
    
    407 392
     
    
    408 393
       static int
    
    409
    -  test_embolden( btimer_t*  timer,
    
    410
    -                 FT_Face    face,
    
    394
    +  test_embolden( FT_Face    face,
    
    411 395
                      void*      user_data )
    
    412 396
       {
    
    413 397
         int  i, done = 0;
    
    ... ... @@ -420,19 +404,16 @@
    420 404
           if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
    
    421 405
             continue;
    
    422 406
     
    
    423
    -      TIMER_START( timer );
    
    424
    -      FT_GlyphSlot_Embolden( face->glyph );
    
    407
    +            FT_GlyphSlot_Embolden( face->glyph );
    
    425 408
           done++;
    
    426
    -      TIMER_STOP( timer );
    
    427
    -    }
    
    409
    +          }
    
    428 410
     
    
    429 411
         return done;
    
    430 412
       }
    
    431 413
     
    
    432 414
     
    
    433 415
       static int
    
    434
    -  test_stroke( btimer_t*  timer,
    
    435
    -               FT_Face    face,
    
    416
    +  test_stroke( FT_Face    face,
    
    436 417
                    void*      user_data )
    
    437 418
       {
    
    438 419
         FT_Glyph    glyph;
    
    ... ... @@ -456,9 +437,7 @@
    456 437
                FT_Get_Glyph( face->glyph, &glyph )            )
    
    457 438
             continue;
    
    458 439
     
    
    459
    -      TIMER_START( timer );
    
    460
    -      FT_Glyph_Stroke( &glyph, stroker, 1 );
    
    461
    -      TIMER_STOP( timer );
    
    440
    +            FT_Glyph_Stroke( &glyph, stroker, 1 );
    
    462 441
     
    
    463 442
           FT_Done_Glyph( glyph );
    
    464 443
           done++;
    
    ... ... @@ -471,8 +450,7 @@
    471 450
     
    
    472 451
     
    
    473 452
       static int
    
    474
    -  test_get_glyph( btimer_t*  timer,
    
    475
    -                  FT_Face    face,
    
    453
    +  test_get_glyph( FT_Face    face,
    
    476 454
                       void*      user_data )
    
    477 455
       {
    
    478 456
         FT_Glyph  glyph;
    
    ... ... @@ -487,22 +465,19 @@
    487 465
           if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
    
    488 466
             continue;
    
    489 467
     
    
    490
    -      TIMER_START( timer );
    
    491
    -      if ( !FT_Get_Glyph( face->glyph, &glyph ) )
    
    468
    +            if ( !FT_Get_Glyph( face->glyph, &glyph ) )
    
    492 469
           {
    
    493 470
             FT_Done_Glyph( glyph );
    
    494 471
             done++;
    
    495 472
           }
    
    496
    -      TIMER_STOP( timer );
    
    497
    -    }
    
    473
    +          }
    
    498 474
     
    
    499 475
         return done;
    
    500 476
       }
    
    501 477
     
    
    502 478
     
    
    503 479
       static int
    
    504
    -  test_get_cbox( btimer_t*  timer,
    
    505
    -                 FT_Face    face,
    
    480
    +  test_get_cbox( FT_Face    face,
    
    506 481
                      void*      user_data )
    
    507 482
       {
    
    508 483
         FT_Glyph  glyph;
    
    ... ... @@ -521,9 +496,7 @@
    521 496
           if ( FT_Get_Glyph( face->glyph, &glyph ) )
    
    522 497
             continue;
    
    523 498
     
    
    524
    -      TIMER_START( timer );
    
    525
    -      FT_Glyph_Get_CBox( glyph, FT_GLYPH_BBOX_PIXELS, &bbox );
    
    526
    -      TIMER_STOP( timer );
    
    499
    +            FT_Glyph_Get_CBox( glyph, FT_GLYPH_BBOX_PIXELS, &bbox );
    
    527 500
     
    
    528 501
           FT_Done_Glyph( glyph );
    
    529 502
           done++;
    
    ... ... @@ -534,8 +507,7 @@
    534 507
     
    
    535 508
     
    
    536 509
       static int
    
    537
    -  test_get_bbox( btimer_t*  timer,
    
    538
    -                 FT_Face    face,
    
    510
    +  test_get_bbox( FT_Face    face,
    
    539 511
                      void*      user_data )
    
    540 512
       {
    
    541 513
         FT_BBox    bbox;
    
    ... ... @@ -550,9 +522,7 @@
    550 522
           if ( FT_Load_Glyph( face, (FT_UInt)i, load_flags ) )
    
    551 523
             continue;
    
    552 524
     
    
    553
    -      TIMER_START( timer );
    
    554
    -      FT_Outline_Get_BBox( &face->glyph->outline, &bbox );
    
    555
    -      TIMER_STOP( timer );
    
    525
    +            FT_Outline_Get_BBox( &face->glyph->outline, &bbox );
    
    556 526
     
    
    557 527
           done++;
    
    558 528
         }
    
    ... ... @@ -562,31 +532,25 @@
    562 532
     
    
    563 533
     
    
    564 534
       static int
    
    565
    -  test_get_char_index( btimer_t*  timer,
    
    566
    -                       FT_Face    face,
    
    535
    +  test_get_char_index( FT_Face    face,
    
    567 536
                            void*      user_data )
    
    568 537
       {
    
    569 538
         bcharset_t*  charset = (bcharset_t*)user_data;
    
    570 539
         int          i, done = 0;
    
    571 540
     
    
    572 541
     
    
    573
    -    TIMER_START( timer );
    
    574
    -
    
    575 542
         for ( i = 0; i < charset->size; i++ )
    
    576 543
         {
    
    577 544
           if ( FT_Get_Char_Index(face, charset->code[i]) )
    
    578 545
             done++;
    
    579 546
         }
    
    580 547
     
    
    581
    -    TIMER_STOP( timer );
    
    582
    -
    
    583 548
         return done;
    
    584 549
       }
    
    585 550
     
    
    586 551
     
    
    587 552
       static int
    
    588
    -  test_cmap_cache( btimer_t*  timer,
    
    589
    -                   FT_Face    face,
    
    553
    +  test_cmap_cache( FT_Face    face,
    
    590 554
                        void*      user_data )
    
    591 555
       {
    
    592 556
         bcharset_t*  charset = (bcharset_t*)user_data;
    
    ... ... @@ -595,8 +559,6 @@
    595 559
         FT_UNUSED( face );
    
    596 560
     
    
    597 561
     
    
    598
    -    TIMER_START( timer );
    
    599
    -
    
    600 562
         for ( i = 0; i < charset->size; i++ )
    
    601 563
         {
    
    602 564
           if ( FTC_CMapCache_Lookup( cmap_cache,
    
    ... ... @@ -606,15 +568,12 @@
    606 568
             done++;
    
    607 569
         }
    
    608 570
     
    
    609
    -    TIMER_STOP( timer );
    
    610
    -
    
    611 571
         return done;
    
    612 572
       }
    
    613 573
     
    
    614 574
     
    
    615 575
       static int
    
    616
    -  test_image_cache( btimer_t*  timer,
    
    617
    -                    FT_Face    face,
    
    576
    +  test_image_cache( FT_Face    face,
    
    618 577
                         void*      user_data )
    
    619 578
       {
    
    620 579
         FT_Glyph  glyph;
    
    ... ... @@ -624,9 +583,6 @@
    624 583
         FT_UNUSED( face );
    
    625 584
         FT_UNUSED( user_data );
    
    626 585
     
    
    627
    -
    
    628
    -    TIMER_START( timer );
    
    629
    -
    
    630 586
         FOREACH( i )
    
    631 587
         {
    
    632 588
           if ( !FTC_ImageCache_Lookup( image_cache,
    
    ... ... @@ -637,15 +593,12 @@
    637 593
             done++;
    
    638 594
         }
    
    639 595
     
    
    640
    -    TIMER_STOP( timer );
    
    641
    -
    
    642 596
         return done;
    
    643 597
       }
    
    644 598
     
    
    645 599
     
    
    646 600
       static int
    
    647
    -  test_sbit_cache( btimer_t*  timer,
    
    648
    -                   FT_Face    face,
    
    601
    +  test_sbit_cache( FT_Face    face,
    
    649 602
                        void*      user_data )
    
    650 603
       {
    
    651 604
         FTC_SBit  glyph;
    
    ... ... @@ -655,9 +608,6 @@
    655 608
         FT_UNUSED( face );
    
    656 609
         FT_UNUSED( user_data );
    
    657 610
     
    
    658
    -
    
    659
    -    TIMER_START( timer );
    
    660
    -
    
    661 611
         FOREACH( i )
    
    662 612
         {
    
    663 613
           if ( !FTC_SBitCache_Lookup( sbit_cache,
    
    ... ... @@ -668,15 +618,12 @@
    668 618
             done++;
    
    669 619
         }
    
    670 620
     
    
    671
    -    TIMER_STOP( timer );
    
    672
    -
    
    673 621
         return done;
    
    674 622
       }
    
    675 623
     
    
    676 624
     
    
    677 625
       static int
    
    678
    -  test_cmap_iter( btimer_t*  timer,
    
    679
    -                  FT_Face    face,
    
    626
    +  test_cmap_iter( FT_Face    face,
    
    680 627
                       void*      user_data )
    
    681 628
       {
    
    682 629
         FT_UInt   idx;
    
    ... ... @@ -686,23 +633,18 @@
    686 633
         FT_UNUSED( user_data );
    
    687 634
     
    
    688 635
     
    
    689
    -    TIMER_START( timer );
    
    690
    -
    
    691 636
         charcode = FT_Get_First_Char( face, &idx );
    
    692 637
         done = ( idx != 0 );
    
    693 638
     
    
    694 639
         while ( idx != 0 )
    
    695 640
           charcode = FT_Get_Next_Char( face, charcode, &idx );
    
    696 641
     
    
    697
    -    TIMER_STOP( timer );
    
    698
    -
    
    699
    -    return done;
    
    642
    +        return done;
    
    700 643
       }
    
    701 644
     
    
    702 645
     
    
    703 646
       static int
    
    704
    -  test_new_face( btimer_t*  timer,
    
    705
    -                 FT_Face    face,
    
    647
    +  test_new_face( FT_Face    face,
    
    706 648
                      void*      user_data )
    
    707 649
       {
    
    708 650
         FT_Face  bench_face;
    
    ... ... @@ -711,20 +653,15 @@
    711 653
         FT_UNUSED( user_data );
    
    712 654
     
    
    713 655
     
    
    714
    -    TIMER_START( timer );
    
    715
    -
    
    716 656
         if ( !get_face( &bench_face ) )
    
    717 657
           FT_Done_Face( bench_face );
    
    718 658
     
    
    719
    -    TIMER_STOP( timer );
    
    720
    -
    
    721
    -    return 1;
    
    659
    +        return 1;
    
    722 660
       }
    
    723 661
     
    
    724 662
     
    
    725 663
       static int
    
    726
    -  test_new_face_and_load_glyph( btimer_t*  timer,
    
    727
    -                                FT_Face    face,
    
    664
    +  test_new_face_and_load_glyph( FT_Face    face,
    
    728 665
                                     void*      user_data )
    
    729 666
       {
    
    730 667
         FT_Face  bench_face;
    
    ... ... @@ -735,8 +672,6 @@
    735 672
         FT_UNUSED( user_data );
    
    736 673
     
    
    737 674
     
    
    738
    -    TIMER_START( timer );
    
    739
    -
    
    740 675
         if ( !get_face( &bench_face ) )
    
    741 676
         {
    
    742 677
           FOREACH( i )
    
    ... ... @@ -748,8 +683,6 @@
    748 683
           FT_Done_Face( bench_face );
    
    749 684
         }
    
    750 685
     
    
    751
    -    TIMER_STOP( timer );
    
    752
    -
    
    753 686
         return done;
    
    754 687
       }
    
    755 688
     
    
    ... ... @@ -1103,6 +1036,10 @@
    1103 1036
       {
    
    1104 1037
         FT_Face   face;
    
    1105 1038
         FT_Error  error;
    
    1039
    +    btimer_t total;
    
    1040
    +
    
    1041
    +    TIMER_RESET(&total);
    
    1042
    +    TIMER_START(&total);
    
    1106 1043
     
    
    1107 1044
         unsigned long  max_bytes      = CACHE_SIZE * 1024;
    
    1108 1045
         char*          test_string    = NULL;
    
    ... ... @@ -1356,6 +1293,9 @@
    1356 1293
             if ( warmup_iter < 0 )
    
    1357 1294
               warmup_iter = -warmup_iter;
    
    1358 1295
             break;
    
    1296
    +
    
    1297
    +
    
    1298
    +
    
    1359 1299
             /* break; */
    
    1360 1300
     
    
    1361 1301
           default:
    
    ... ... @@ -1616,6 +1556,9 @@
    1616 1556
             break;
    
    1617 1557
           }
    
    1618 1558
         }
    
    1559
    +    TIMER_STOP(&total);
    
    1560
    +    double total_time = TIMER_GET(&total);
    
    1561
    +    printf("\nTotal time: %.0fs\n", total_time/1000000);
    
    1619 1562
     
    
    1620 1563
         if ( cache_man )
    
    1621 1564
           FTC_Manager_Done( cache_man );
    


  • reply via email to

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