diff --git a/perf/benchmark-subset.cc b/perf/benchmark-subset.cc index a8d03ef27..852e81038 100644 --- a/perf/benchmark-subset.cc +++ b/perf/benchmark-subset.cc @@ -12,16 +12,17 @@ void AddCodepoints(const hb_set_t* codepoints_in_font, hb_codepoint_t cp = HB_SET_VALUE_INVALID; for (unsigned i = 0; i < subset_size; i++) { // TODO(garretrieger): pick randomly. - assert (hb_set_next (codepoints_in_font, &cp)); + if (!hb_set_next (codepoints_in_font, &cp)) return; hb_set_add (hb_subset_input_unicode_set (input), cp); } } /* benchmark for subsetting a font */ static void BM_subset_codepoints (benchmark::State &state, - const char *font_path, - unsigned subset_size) + const char *font_path) { + unsigned subset_size = state.range(0); + hb_face_t *face; { hb_blob_t *blob = hb_blob_create_from_file_or_fail (font_path); @@ -53,21 +54,34 @@ static void BM_subset_codepoints (benchmark::State &state, hb_face_destroy (face); } -// TODO(garretrieger): Use range() for subset size. -BENCHMARK_CAPTURE (BM_subset_codepoints, subset_roboto_10, - "perf/fonts/Roboto-Regular.ttf", 10) - ->Unit(benchmark::kMicrosecond); +BENCHMARK_CAPTURE (BM_subset_codepoints, subset_roboto, + "perf/fonts/Roboto-Regular.ttf") + ->Unit(benchmark::kMillisecond) + ->Range(10, 4000); -BENCHMARK_CAPTURE (BM_subset_codepoints, subset_roboto_100, - "perf/fonts/Roboto-Regular.ttf", 100) - ->Unit(benchmark::kMicrosecond); +BENCHMARK_CAPTURE (BM_subset_codepoints, subset_amiri, + "perf/fonts/Amiri-Regular.ttf") + ->Unit(benchmark::kMillisecond) + ->Range(10, 4000); -BENCHMARK_CAPTURE (BM_subset_codepoints, subset_noto_nastaliq_urdu_10, - "perf/fonts/NotoNastaliqUrdu-Regular.ttf", 10) - ->Unit(benchmark::kMicrosecond); +BENCHMARK_CAPTURE (BM_subset_codepoints, subset_noto_nastaliq_urdu, + "perf/fonts/NotoNastaliqUrdu-Regular.ttf") + ->Unit(benchmark::kMillisecond) + ->Range(10, 1000); -BENCHMARK_CAPTURE (BM_subset_codepoints, subset_noto_nastaliq_urdu_100, - "perf/fonts/NotoNastaliqUrdu-Regular.ttf", 100) - ->Unit(benchmark::kMicrosecond); +BENCHMARK_CAPTURE (BM_subset_codepoints, subset_noto_devangari, + "perf/fonts/NotoSansDevanagari-Regular.ttf") + ->Unit(benchmark::kMillisecond) + ->Range(10, 1000); + +BENCHMARK_CAPTURE (BM_subset_codepoints, subset_mplus1p, + "perf/fonts/Mplus1p-Regular.ttf") + ->Unit(benchmark::kMillisecond) + ->Range(10, 10000); + +BENCHMARK_CAPTURE (BM_subset_codepoints, subset_notocjk, + "perf/fonts/NotoSansCJKsc-VF.ttf") + ->Unit(benchmark::kMillisecond) + ->Range(10, 100000); BENCHMARK_MAIN(); diff --git a/perf/fonts/Mplus1p-Regular.ttf b/perf/fonts/Mplus1p-Regular.ttf new file mode 100644 index 000000000..f89a28ef3 Binary files /dev/null and b/perf/fonts/Mplus1p-Regular.ttf differ diff --git a/perf/fonts/NotoSansCJKsc-VF.ttf b/perf/fonts/NotoSansCJKsc-VF.ttf new file mode 100644 index 000000000..e67840913 Binary files /dev/null and b/perf/fonts/NotoSansCJKsc-VF.ttf differ