Ahmet Göksu pushed to branch gsoc-2023-ahmet-final at FreeType / FreeType
Commits:
-
8797ad3d
by goksu at 2023-09-21T14:53:49+03:00
[ftbench] warmup added
added '-w N' argument (10 by default), runs N times of iterations before all tests.
1 changed file:
Changes:
src/tools/ftbench/ftbench.c
... |
... |
@@ -99,6 +99,7 @@ |
99
|
99
|
#define CACHE_SIZE 1024
|
100
|
100
|
#define BENCH_TIME 2.0
|
101
|
101
|
#define FACE_SIZE 10
|
|
102
|
+#define WARMUP_ITER 10
|
102
|
103
|
|
103
|
104
|
|
104
|
105
|
static FT_Library lib;
|
... |
... |
@@ -268,7 +269,8 @@ |
268
|
269
|
benchmark( FT_Face face,
|
269
|
270
|
btest_t* test,
|
270
|
271
|
int max_iter,
|
271
|
|
- double max_time )
|
|
272
|
+ double max_time,
|
|
273
|
+ double warmup )
|
272
|
274
|
{
|
273
|
275
|
int n, done;
|
274
|
276
|
btimer_t timer, elapsed;
|
... |
... |
@@ -280,6 +282,11 @@ |
280
|
282
|
test->bench( &timer, face, test->user_data );
|
281
|
283
|
}
|
282
|
284
|
|
|
285
|
+ TIMER_START(&elapsed);
|
|
286
|
+ for(int i = 0; i<warmup; i++)
|
|
287
|
+ test->bench( &timer,face, test->user_data);
|
|
288
|
+ TIMER_STOP(&elapsed);
|
|
289
|
+
|
283
|
290
|
printf( " %-25s ", test->title );
|
284
|
291
|
fflush( stdout );
|
285
|
292
|
|
... |
... |
@@ -1049,6 +1056,7 @@ |
1049
|
1056
|
FACE_SIZE );
|
1050
|
1057
|
fprintf( stderr,
|
1051
|
1058
|
" -t T Use at most T seconds per bench (default is %.0f).\n"
|
|
1059
|
+ " -w N Use N iterations for warming up before each test\n"
|
1052
|
1060
|
"\n"
|
1053
|
1061
|
" -b tests Perform chosen tests (default is all):\n",
|
1054
|
1062
|
BENCH_TIME );
|
... |
... |
@@ -1101,6 +1109,7 @@ |
1101
|
1109
|
unsigned int size = FACE_SIZE;
|
1102
|
1110
|
int max_iter = 0;
|
1103
|
1111
|
double max_time = BENCH_TIME;
|
|
1112
|
+ int warmup_iter = WARMUP_ITER;
|
1104
|
1113
|
int j;
|
1105
|
1114
|
|
1106
|
1115
|
unsigned int versions[2] = { TT_INTERPRETER_VERSION_35,
|
... |
... |
@@ -1172,7 +1181,7 @@ |
1172
|
1181
|
int opt;
|
1173
|
1182
|
|
1174
|
1183
|
|
1175
|
|
- opt = getopt( argc, argv, "a:b:Cc:e:f:H:I:i:l:m:pr:s:t:v" );
|
|
1184
|
+ opt = getopt( argc, argv, "a:b:Cc:e:f:H:I:i:l:m:pr:s:t:w:v" );
|
1176
|
1185
|
|
1177
|
1186
|
if ( opt == -1 )
|
1178
|
1187
|
break;
|
... |
... |
@@ -1340,6 +1349,13 @@ |
1340
|
1349
|
printf( "\n" );
|
1341
|
1350
|
exit( 0 );
|
1342
|
1351
|
}
|
|
1352
|
+ break;
|
|
1353
|
+
|
|
1354
|
+ case 'w':
|
|
1355
|
+ warmup_iter = atoi( optarg );
|
|
1356
|
+ if ( warmup_iter < 0 )
|
|
1357
|
+ warmup_iter = -warmup_iter;
|
|
1358
|
+ break;
|
1343
|
1359
|
/* break; */
|
1344
|
1360
|
|
1345
|
1361
|
default:
|
... |
... |
@@ -1428,6 +1444,8 @@ |
1428
|
1444
|
if ( max_iter )
|
1429
|
1445
|
printf( "number of iterations for each test: at most %d\n",
|
1430
|
1446
|
max_iter );
|
|
1447
|
+ printf( "number of iterations as warmup in all tests: %d\n",
|
|
1448
|
+ warmup_iter );
|
1431
|
1449
|
|
1432
|
1450
|
printf( "\n"
|
1433
|
1451
|
"executing tests:\n" );
|
... |
... |
@@ -1451,7 +1469,7 @@ |
1451
|
1469
|
case FT_BENCH_LOAD_GLYPH:
|
1452
|
1470
|
test.title = "Load";
|
1453
|
1471
|
test.bench = test_load;
|
1454
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1472
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1455
|
1473
|
|
1456
|
1474
|
if ( cache_man )
|
1457
|
1475
|
{
|
... |
... |
@@ -1461,7 +1479,7 @@ |
1461
|
1479
|
{
|
1462
|
1480
|
test.title = "Load (image cached)";
|
1463
|
1481
|
test.bench = test_image_cache;
|
1464
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1482
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1465
|
1483
|
}
|
1466
|
1484
|
|
1467
|
1485
|
if ( !FTC_SBitCache_New( cache_man, &sbit_cache ) )
|
... |
... |
@@ -1469,7 +1487,7 @@ |
1469
|
1487
|
test.title = "Load (sbit cached)";
|
1470
|
1488
|
test.bench = test_sbit_cache;
|
1471
|
1489
|
if ( size )
|
1472
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1490
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1473
|
1491
|
else
|
1474
|
1492
|
printf( " %-25s disabled (size = 0)\n", test.title );
|
1475
|
1493
|
}
|
... |
... |
@@ -1482,24 +1500,24 @@ |
1482
|
1500
|
test.title = "Load_Advances (Normal)";
|
1483
|
1501
|
test.bench = test_load_advances;
|
1484
|
1502
|
flags = FT_LOAD_DEFAULT;
|
1485
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1503
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1486
|
1504
|
|
1487
|
1505
|
test.title = "Load_Advances (Fast)";
|
1488
|
1506
|
test.bench = test_load_advances;
|
1489
|
1507
|
flags = FT_LOAD_TARGET_LIGHT;
|
1490
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1508
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1491
|
1509
|
|
1492
|
1510
|
test.title = "Load_Advances (Unscaled)";
|
1493
|
1511
|
test.bench = test_load_advances;
|
1494
|
1512
|
flags = FT_LOAD_NO_SCALE;
|
1495
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1513
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1496
|
1514
|
break;
|
1497
|
1515
|
|
1498
|
1516
|
case FT_BENCH_RENDER:
|
1499
|
1517
|
test.title = "Render";
|
1500
|
1518
|
test.bench = test_render;
|
1501
|
1519
|
if ( size )
|
1502
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1520
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1503
|
1521
|
else
|
1504
|
1522
|
printf( " %-25s disabled (size = 0)\n", test.title );
|
1505
|
1523
|
break;
|
... |
... |
@@ -1507,13 +1525,13 @@ |
1507
|
1525
|
case FT_BENCH_GET_GLYPH:
|
1508
|
1526
|
test.title = "Get_Glyph";
|
1509
|
1527
|
test.bench = test_get_glyph;
|
1510
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1528
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1511
|
1529
|
break;
|
1512
|
1530
|
|
1513
|
1531
|
case FT_BENCH_GET_CBOX:
|
1514
|
1532
|
test.title = "Get_CBox";
|
1515
|
1533
|
test.bench = test_get_cbox;
|
1516
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1534
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1517
|
1535
|
break;
|
1518
|
1536
|
|
1519
|
1537
|
case FT_BENCH_GET_BBOX:
|
... |
... |
@@ -1525,7 +1543,7 @@ |
1525
|
1543
|
|
1526
|
1544
|
/* rotate outlines by 30 degrees so that CBox and BBox differ */
|
1527
|
1545
|
FT_Set_Transform( face, &rot30, NULL );
|
1528
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1546
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1529
|
1547
|
FT_Set_Transform( face, NULL, NULL );
|
1530
|
1548
|
}
|
1531
|
1549
|
break;
|
... |
... |
@@ -1544,7 +1562,7 @@ |
1544
|
1562
|
test.title = "Get_Char_Index";
|
1545
|
1563
|
test.bench = test_get_char_index;
|
1546
|
1564
|
|
1547
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1565
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1548
|
1566
|
|
1549
|
1567
|
if ( cache_man &&
|
1550
|
1568
|
!FTC_CMapCache_New( cache_man, &cmap_cache ) )
|
... |
... |
@@ -1553,7 +1571,7 @@ |
1553
|
1571
|
|
1554
|
1572
|
test.title = "Get_Char_Index (cached)";
|
1555
|
1573
|
test.bench = test_cmap_cache;
|
1556
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1574
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1557
|
1575
|
}
|
1558
|
1576
|
|
1559
|
1577
|
free( charset.code );
|
... |
... |
@@ -1564,20 +1582,20 @@ |
1564
|
1582
|
case FT_BENCH_CMAP_ITER:
|
1565
|
1583
|
test.title = "Iterate CMap";
|
1566
|
1584
|
test.bench = test_cmap_iter;
|
1567
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1585
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1568
|
1586
|
break;
|
1569
|
1587
|
|
1570
|
1588
|
case FT_BENCH_NEW_FACE:
|
1571
|
1589
|
test.title = "New_Face";
|
1572
|
1590
|
test.bench = test_new_face;
|
1573
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1591
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1574
|
1592
|
break;
|
1575
|
1593
|
|
1576
|
1594
|
case FT_BENCH_EMBOLDEN:
|
1577
|
1595
|
test.title = "Embolden";
|
1578
|
1596
|
test.bench = test_embolden;
|
1579
|
1597
|
if ( size )
|
1580
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1598
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1581
|
1599
|
else
|
1582
|
1600
|
printf( " %-25s disabled (size = 0)\n", test.title );
|
1583
|
1601
|
break;
|
... |
... |
@@ -1586,7 +1604,7 @@ |
1586
|
1604
|
test.title = "Stroke";
|
1587
|
1605
|
test.bench = test_stroke;
|
1588
|
1606
|
if ( size )
|
1589
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1607
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1590
|
1608
|
else
|
1591
|
1609
|
printf( " %-25s disabled (size = 0)\n", test.title );
|
1592
|
1610
|
break;
|
... |
... |
@@ -1594,7 +1612,7 @@ |
1594
|
1612
|
case FT_BENCH_NEW_FACE_AND_LOAD_GLYPH:
|
1595
|
1613
|
test.title = "New_Face & load glyph(s)";
|
1596
|
1614
|
test.bench = test_new_face_and_load_glyph;
|
1597
|
|
- benchmark( face, &test, max_iter, max_time );
|
|
1615
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1598
|
1616
|
break;
|
1599
|
1617
|
}
|
1600
|
1618
|
}
|
|