[perf] Add benchmark-ot

This commit is contained in:
Behdad Esfahbod 2022-05-17 13:12:17 -06:00
parent 629fa8ee87
commit 26d906b88b
3 changed files with 46 additions and 0 deletions

View File

@ -8,6 +8,7 @@ EXTRA_DIST += \
meson.build \
benchmark-font.cc \
benchmark-map.cc \
benchmark-ot.cc \
benchmark-set.cc \
benchmark-shape.cc \
benchmark-subset.cc \

35
perf/benchmark-ot.cc Normal file
View File

@ -0,0 +1,35 @@
/*
* Benchmarks for hb_set_t operations.
*/
#include "benchmark/benchmark.h"
#include "hb-ot.h"
static void BM_hb_ot_tags_from_script_and_language (benchmark::State& state,
hb_script_t script,
const char *language_str) {
hb_language_t language = hb_language_from_string (language_str, -1);
hb_tag_t script_tags[HB_OT_MAX_TAGS_PER_SCRIPT];
unsigned script_count = HB_OT_MAX_TAGS_PER_SCRIPT;
hb_tag_t language_tags[HB_OT_MAX_TAGS_PER_LANGUAGE];
unsigned language_count = HB_OT_MAX_TAGS_PER_LANGUAGE;
for (auto _ : state) {
hb_ot_tags_from_script_and_language (script,
language,
&script_count /* IN/OUT */,
script_tags /* OUT */,
&language_count /* IN/OUT */,
language_tags /* OUT */);
}
}
BENCHMARK_CAPTURE (BM_hb_ot_tags_from_script_and_language, COMMON zh_CN, HB_SCRIPT_COMMON, "zh_CN");
BENCHMARK_CAPTURE (BM_hb_ot_tags_from_script_and_language, COMMON en_US, HB_SCRIPT_COMMON, "en_US");
BENCHMARK_CAPTURE (BM_hb_ot_tags_from_script_and_language, LATIN en_US, HB_SCRIPT_LATIN, "en_US");
BENCHMARK_CAPTURE (BM_hb_ot_tags_from_script_and_language, COMMON none, HB_SCRIPT_LATIN, nullptr);
BENCHMARK_CAPTURE (BM_hb_ot_tags_from_script_and_language, LATIN none, HB_SCRIPT_LATIN, nullptr);
BENCHMARK_MAIN();

View File

@ -21,6 +21,16 @@ benchmark('benchmark-map', executable('benchmark-map', 'benchmark-map.cc',
install: false,
), workdir: meson.current_source_dir() / '..', timeout: 100)
benchmark('benchmark-ot', executable('benchmark-ot', 'benchmark-ot.cc',
dependencies: [
google_benchmark_dep,
],
cpp_args: [],
include_directories: [incconfig, incsrc],
link_with: [libharfbuzz],
install: false,
), workdir: meson.current_source_dir() / '..', timeout: 100)
benchmark('benchmark-set', executable('benchmark-set', 'benchmark-set.cc',
dependencies: [
google_benchmark_dep,