Ahmet Göksu pushed to branch GSoC-2023-Ahmet at FreeType / FreeType
Commits:
3 changed files:
Changes:
builds/testing.mk
... |
... |
@@ -3,7 +3,7 @@ FTBENCH_DIR = $(TOP_DIR)/src/tools/ftbench |
3
|
3
|
FTBENCH_SRC = $(FTBENCH_DIR)/ftbench.c
|
4
|
4
|
FTBENCH_OBJ = $(OBJ_DIR)/bench.$(SO)
|
5
|
5
|
FTBENCH_BIN = $(OBJ_DIR)/bench$E
|
6
|
|
-FTBENCH_FLAG ?= -c 500 -w 1
|
|
6
|
+FTBENCH_FLAG ?= -c 1000 -w 100
|
7
|
7
|
INCLUDES = $(TOP_DIR)/include
|
8
|
8
|
FONTS = $(wildcard $(FTBENCH_DIR)/fonts/*.ttf)
|
9
|
9
|
BASELINE_DIR = $(OBJ_DIR)/baseline/
|
src/tools/ftbench/ftbench.c
... |
... |
@@ -98,7 +98,7 @@ |
98
|
98
|
|
99
|
99
|
#define CACHE_SIZE 1024
|
100
|
100
|
#define BENCH_TIME 2.0
|
101
|
|
-#define WARMUP_TIME 1.0
|
|
101
|
+#define WARMUP_ITER 0
|
102
|
102
|
#define FACE_SIZE 10
|
103
|
103
|
|
104
|
104
|
|
... |
... |
@@ -275,7 +275,7 @@ |
275
|
275
|
|
276
|
276
|
int n, done;
|
277
|
277
|
btimer_t timer, elapsed;
|
278
|
|
- double warmup_time = warmup * 1E6; // Convert to microseconds
|
|
278
|
+
|
279
|
279
|
|
280
|
280
|
if ( test->cache_first )
|
281
|
281
|
{
|
... |
... |
@@ -293,8 +293,12 @@ |
293
|
293
|
|
294
|
294
|
for ( n = 0, done = 0; !max_iter || n < max_iter; n++ )
|
295
|
295
|
{
|
296
|
|
- if ( is_warmup )
|
297
|
|
- n = 0;
|
|
296
|
+ if ( is_warmup && n == warmup ){
|
|
297
|
+ is_warmup = 0;
|
|
298
|
+ TIMER_RESET( &timer );
|
|
299
|
+ TIMER_RESET( &elapsed );
|
|
300
|
+ }
|
|
301
|
+
|
298
|
302
|
|
299
|
303
|
TIMER_START( &elapsed );
|
300
|
304
|
|
... |
... |
@@ -302,21 +306,14 @@ |
302
|
306
|
|
303
|
307
|
TIMER_STOP( &elapsed );
|
304
|
308
|
|
305
|
|
- if ( is_warmup && TIMER_GET( &elapsed ) > warmup_time )
|
306
|
|
- {
|
307
|
|
- is_warmup = 0;
|
308
|
|
- done = 0;
|
309
|
|
- TIMER_RESET( &timer );
|
310
|
|
- TIMER_RESET( &elapsed );
|
311
|
|
- }
|
312
|
|
-
|
313
|
|
- else if ( !is_warmup && TIMER_GET( &elapsed ) > 1E6 * max_time )
|
|
309
|
+
|
|
310
|
+ if (!is_warmup && TIMER_GET( &elapsed ) > 1E6 * max_time )
|
314
|
311
|
break;
|
315
|
312
|
}
|
316
|
313
|
|
317
|
314
|
if ( done )
|
318
|
|
- printf( "%10.3f ms %10d done\n",
|
319
|
|
- TIMER_GET( &timer ) / 1000000, done );
|
|
315
|
+ printf( "%10.1f ms %10d done\n",
|
|
316
|
+ TIMER_GET( &timer ), done );
|
320
|
317
|
else
|
321
|
318
|
printf( "no error-free calls\n" );
|
322
|
319
|
}
|
... |
... |
@@ -1117,7 +1114,7 @@ |
1117
|
1114
|
unsigned int size = FACE_SIZE;
|
1118
|
1115
|
int max_iter = 0;
|
1119
|
1116
|
double max_time = BENCH_TIME;
|
1120
|
|
- double warmup_time = WARMUP_TIME;
|
|
1117
|
+ int warmup_iter = WARMUP_ITER;
|
1121
|
1118
|
int j;
|
1122
|
1119
|
|
1123
|
1120
|
unsigned int versions[2] = { TT_INTERPRETER_VERSION_35,
|
... |
... |
@@ -1360,10 +1357,11 @@ |
1360
|
1357
|
break;
|
1361
|
1358
|
|
1362
|
1359
|
case 'w':
|
1363
|
|
- warmup_time = atof( optarg );
|
1364
|
|
- if ( warmup_time < 0 )
|
1365
|
|
- warmup_time = -warmup_time;
|
|
1360
|
+ warmup_iter = atoi( optarg );
|
|
1361
|
+ if ( warmup_iter < 0 )
|
|
1362
|
+ warmup_iter = -warmup_iter;
|
1366
|
1363
|
break;
|
|
1364
|
+
|
1367
|
1365
|
|
1368
|
1366
|
|
1369
|
1367
|
/* break; */
|
... |
... |
@@ -1454,8 +1452,8 @@ |
1454
|
1452
|
if ( max_iter )
|
1455
|
1453
|
printf( "number of iterations for each test: at most %d\n",
|
1456
|
1454
|
max_iter );
|
1457
|
|
- printf( "number of seconds as warmup time before all tests: %.0f\n",
|
1458
|
|
- warmup_time );
|
|
1455
|
+ printf( "number of iteration as warmup in all tests: %d\n",
|
|
1456
|
+ warmup_iter );
|
1459
|
1457
|
|
1460
|
1458
|
printf( "\n"
|
1461
|
1459
|
"executing tests:\n" );
|
... |
... |
@@ -1479,7 +1477,7 @@ |
1479
|
1477
|
case FT_BENCH_LOAD_GLYPH:
|
1480
|
1478
|
test.title = "Load";
|
1481
|
1479
|
test.bench = test_load;
|
1482
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1480
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1483
|
1481
|
|
1484
|
1482
|
if ( cache_man )
|
1485
|
1483
|
{
|
... |
... |
@@ -1489,7 +1487,7 @@ |
1489
|
1487
|
{
|
1490
|
1488
|
test.title = "Load (image cached)";
|
1491
|
1489
|
test.bench = test_image_cache;
|
1492
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1490
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1493
|
1491
|
}
|
1494
|
1492
|
|
1495
|
1493
|
if ( !FTC_SBitCache_New( cache_man, &sbit_cache ) )
|
... |
... |
@@ -1497,7 +1495,7 @@ |
1497
|
1495
|
test.title = "Load (sbit cached)";
|
1498
|
1496
|
test.bench = test_sbit_cache;
|
1499
|
1497
|
if ( size )
|
1500
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1498
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1501
|
1499
|
else
|
1502
|
1500
|
printf( " %-25s disabled (size = 0)\n", test.title );
|
1503
|
1501
|
}
|
... |
... |
@@ -1510,24 +1508,24 @@ |
1510
|
1508
|
test.title = "Load_Advances (Normal)";
|
1511
|
1509
|
test.bench = test_load_advances;
|
1512
|
1510
|
flags = FT_LOAD_DEFAULT;
|
1513
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1511
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1514
|
1512
|
|
1515
|
1513
|
test.title = "Load_Advances (Fast)";
|
1516
|
1514
|
test.bench = test_load_advances;
|
1517
|
1515
|
flags = FT_LOAD_TARGET_LIGHT;
|
1518
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1516
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1519
|
1517
|
|
1520
|
1518
|
test.title = "Load_Advances (Unscaled)";
|
1521
|
1519
|
test.bench = test_load_advances;
|
1522
|
1520
|
flags = FT_LOAD_NO_SCALE;
|
1523
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1521
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1524
|
1522
|
break;
|
1525
|
1523
|
|
1526
|
1524
|
case FT_BENCH_RENDER:
|
1527
|
1525
|
test.title = "Render";
|
1528
|
1526
|
test.bench = test_render;
|
1529
|
1527
|
if ( size )
|
1530
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1528
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1531
|
1529
|
else
|
1532
|
1530
|
printf( " %-25s disabled (size = 0)\n", test.title );
|
1533
|
1531
|
break;
|
... |
... |
@@ -1535,13 +1533,13 @@ |
1535
|
1533
|
case FT_BENCH_GET_GLYPH:
|
1536
|
1534
|
test.title = "Get_Glyph";
|
1537
|
1535
|
test.bench = test_get_glyph;
|
1538
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1536
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1539
|
1537
|
break;
|
1540
|
1538
|
|
1541
|
1539
|
case FT_BENCH_GET_CBOX:
|
1542
|
1540
|
test.title = "Get_CBox";
|
1543
|
1541
|
test.bench = test_get_cbox;
|
1544
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1542
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1545
|
1543
|
break;
|
1546
|
1544
|
|
1547
|
1545
|
case FT_BENCH_GET_BBOX:
|
... |
... |
@@ -1553,7 +1551,7 @@ |
1553
|
1551
|
|
1554
|
1552
|
/* rotate outlines by 30 degrees so that CBox and BBox differ */
|
1555
|
1553
|
FT_Set_Transform( face, &rot30, NULL );
|
1556
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1554
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1557
|
1555
|
FT_Set_Transform( face, NULL, NULL );
|
1558
|
1556
|
}
|
1559
|
1557
|
break;
|
... |
... |
@@ -1572,7 +1570,7 @@ |
1572
|
1570
|
test.title = "Get_Char_Index";
|
1573
|
1571
|
test.bench = test_get_char_index;
|
1574
|
1572
|
|
1575
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1573
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1576
|
1574
|
|
1577
|
1575
|
if ( cache_man &&
|
1578
|
1576
|
!FTC_CMapCache_New( cache_man, &cmap_cache ) )
|
... |
... |
@@ -1581,7 +1579,7 @@ |
1581
|
1579
|
|
1582
|
1580
|
test.title = "Get_Char_Index (cached)";
|
1583
|
1581
|
test.bench = test_cmap_cache;
|
1584
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1582
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1585
|
1583
|
}
|
1586
|
1584
|
|
1587
|
1585
|
free( charset.code );
|
... |
... |
@@ -1592,20 +1590,20 @@ |
1592
|
1590
|
case FT_BENCH_CMAP_ITER:
|
1593
|
1591
|
test.title = "Iterate CMap";
|
1594
|
1592
|
test.bench = test_cmap_iter;
|
1595
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1593
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1596
|
1594
|
break;
|
1597
|
1595
|
|
1598
|
1596
|
case FT_BENCH_NEW_FACE:
|
1599
|
1597
|
test.title = "New_Face";
|
1600
|
1598
|
test.bench = test_new_face;
|
1601
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1599
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1602
|
1600
|
break;
|
1603
|
1601
|
|
1604
|
1602
|
case FT_BENCH_EMBOLDEN:
|
1605
|
1603
|
test.title = "Embolden";
|
1606
|
1604
|
test.bench = test_embolden;
|
1607
|
1605
|
if ( size )
|
1608
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1606
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1609
|
1607
|
else
|
1610
|
1608
|
printf( " %-25s disabled (size = 0)\n", test.title );
|
1611
|
1609
|
break;
|
... |
... |
@@ -1614,7 +1612,7 @@ |
1614
|
1612
|
test.title = "Stroke";
|
1615
|
1613
|
test.bench = test_stroke;
|
1616
|
1614
|
if ( size )
|
1617
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1615
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1618
|
1616
|
else
|
1619
|
1617
|
printf( " %-25s disabled (size = 0)\n", test.title );
|
1620
|
1618
|
break;
|
... |
... |
@@ -1622,7 +1620,7 @@ |
1622
|
1620
|
case FT_BENCH_NEW_FACE_AND_LOAD_GLYPH:
|
1623
|
1621
|
test.title = "New_Face & load glyph(s)";
|
1624
|
1622
|
test.bench = test_new_face_and_load_glyph;
|
1625
|
|
- benchmark( face, &test, max_iter, max_time, warmup_time );
|
|
1623
|
+ benchmark( face, &test, max_iter, max_time, warmup_iter );
|
1626
|
1624
|
break;
|
1627
|
1625
|
}
|
1628
|
1626
|
}
|
src/tools/ftbench/src/tohtml.py
... |
... |
@@ -103,7 +103,7 @@ def generate_info_table(html_file, baseline_info, benchmark_info): |
103
|
103
|
),
|
104
|
104
|
)
|
105
|
105
|
write_to_html(html_file, "</table><br/>")
|
106
|
|
- write_to_html(html_file, "* Smaller values mean faster operation<br/>\n")
|
|
106
|
+ write_to_html(html_file, "* Cumulative time for iterations which is better in smaller values<br/>\n")
|
107
|
107
|
|
108
|
108
|
|
109
|
109
|
def generate_results_table(html_file, baseline_results, benchmark_results, filename):
|
... |
... |
@@ -119,8 +119,8 @@ def generate_results_table(html_file, baseline_results, benchmark_results, filen |
119
|
119
|
write_to_html(
|
120
|
120
|
html_file,
|
121
|
121
|
'<tr><th>Test</th><th>N</th>\
|
122
|
|
- <th>* <a href="">Baseline</a> (ms)</th>\
|
123
|
|
- <th>* <a href="">Benchmark</a> (ms)</th>\
|
|
122
|
+ <th>* <a href="">Baseline</a> (µs)</th>\
|
|
123
|
+ <th>* <a href="">Benchmark</a> (µs)</th>\
|
124
|
124
|
<th>Difference (%)</th></tr>\n'.format(
|
125
|
125
|
os.path.join(BASELINE_DIR, filename[:-4]),
|
126
|
126
|
os.path.join(BENCHMARK_DIR, filename[:-4]),
|
... |
... |
@@ -159,13 +159,13 @@ def generate_results_table(html_file, baseline_results, benchmark_results, filen |
159
|
159
|
total_n += int(benchmark_n)
|
160
|
160
|
total_time_baseline += baseline_value
|
161
|
161
|
total_time_benchmark += benchmark_value
|
162
|
|
- total_difference += percentage_diff
|
|
162
|
+
|
163
|
163
|
|
164
|
164
|
if baseline_value > benchmark_value:
|
165
|
165
|
write_to_html(
|
166
|
166
|
html_file,
|
167
|
167
|
'<tr><td class="col1">{}</td><td>{}</td>\
|
168
|
|
- <td class="lowlight">{:.3f}</td><td class="highlight">{:.3f}</td><td>{:.1f}</td></tr>\n'.format(
|
|
168
|
+ <td class="lowlight">{:.0f}</td><td class="highlight">{:.0f}</td><td>{:.1f}</td></tr>\n'.format(
|
169
|
169
|
baseline_match.group(1),
|
170
|
170
|
n,
|
171
|
171
|
baseline_value,
|
... |
... |
@@ -177,7 +177,7 @@ def generate_results_table(html_file, baseline_results, benchmark_results, filen |
177
|
177
|
write_to_html(
|
178
|
178
|
html_file,
|
179
|
179
|
'<tr><td class="col1">{}</td><td>{}</td>\
|
180
|
|
- <td class="highlight">{:.3f}</td><td class="lowlight">{:.3f}</td><td>{:.1f}</td></tr>\n'.format(
|
|
180
|
+ <td class="highlight">{:.0f}</td><td class="lowlight">{:.0f}</td><td>{:.1f}</td></tr>\n'.format(
|
181
|
181
|
baseline_match.group(1),
|
182
|
182
|
n,
|
183
|
183
|
baseline_value,
|
... |
... |
@@ -189,8 +189,8 @@ def generate_results_table(html_file, baseline_results, benchmark_results, filen |
189
|
189
|
write_to_html(
|
190
|
190
|
html_file,
|
191
|
191
|
'<tr><td class="col1">TOTAL</td><td class="col1">{}</td>\
|
192
|
|
- <td class="col1">{:.3f}</td><td class="col1">{:.3f}</td><td class="col1">{:.1f}</td></tr>\n'.format(
|
193
|
|
- total_n, total_time_baseline, total_time_benchmark, total_difference / 14
|
|
192
|
+ <td class="col1">{:.0f}</td><td class="col1">{:.0f}</td><td class="col1">{:.1f}</td></tr>\n'.format(
|
|
193
|
+ total_n, total_time_baseline, total_time_benchmark, (total_time_baseline - total_time_benchmark) / total_time_baseline * -100
|
194
|
194
|
),
|
195
|
195
|
)
|
196
|
196
|
write_to_html(html_file, "</table><br/>\n")
|
|