123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- #include "minikin/Hyphenator.h"
- #include <benchmark/benchmark.h>
- #include "FileUtils.h"
- #include "UnicodeUtils.h"
- namespace minikin {
- const char* enUsHyph = "/system/usr/hyphen-data/hyph-en-us.hyb";
- const int enUsMinPrefix = 2;
- const int enUsMinSuffix = 3;
- static void BM_Hyphenator_short_word(benchmark::State& state) {
- Hyphenator* hyphenator = Hyphenator::loadBinary(readWholeFile(enUsHyph).data(), enUsMinPrefix,
- enUsMinSuffix, "en");
- std::vector<uint16_t> word = utf8ToUtf16("hyphen");
- std::vector<HyphenationType> result;
- while (state.KeepRunning()) {
- hyphenator->hyphenate(word, &result);
- }
- }
- BENCHMARK(BM_Hyphenator_short_word);
- static void BM_Hyphenator_long_word(benchmark::State& state) {
- Hyphenator* hyphenator = Hyphenator::loadBinary(readWholeFile(enUsHyph).data(), enUsMinPrefix,
- enUsMinSuffix, "en");
- std::vector<uint16_t> word = utf8ToUtf16("Pneumonoultramicroscopicsilicovolcanoconiosis");
- std::vector<HyphenationType> result;
- while (state.KeepRunning()) {
- hyphenator->hyphenate(word, &result);
- }
- }
- BENCHMARK(BM_Hyphenator_long_word);
- }
|