unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

bidi/bidi_bench_test.mbt
1///|2/// Keep input construction outside the timed closures. Run with:3/// moon bench bidi --target native --release4/// (also --target wasm and --target wasm-gc).5test "bidi classes and paragraphs" (b : @bench.T) {6  for7    (name, input) in [8      ("ASCII", "Hello world, this is a test (of brackets) 12345. ".repeat(32)),9      ("Arabic", "مرحبا بالعالم (اختبار) 123 ".repeat(32)),10      (11        "mixed",12        "Hello مرحبا world بالعالم [test] 12,345.67 ".repeat(32),13      ),14      ("CJK", "世界こんにちは、テスト。".repeat(64)),15      ("supplementary", "𐤀𐤁𐤂 😀 𝒜𝒷 ".repeat(64)),16      (17        "explicit formatting",18        "abc \u{2067}\u{05E9}\u{05DC}\u{05D5}\u{05DD} (x) 12\u{2069} def \u{202B}\u{05E2}\u{05D1}\u{05E8}\u{05D9}\u{05EA}\u{202C} ".repeat(19          32,20        ),21      ),22      ("nested brackets", "a (b [c {d} \u{05D0}] 1) \u{05D1} ".repeat(48)),23    ] {24    b.bench(name="bidi_class/\{name}", fn() {25      let mut strong_ltr = 026      for c in input {27        if @bidi.bidi_class(c) is L {28          strong_ltr += 129        }30      }31      b.keep(strong_ltr)32    })33    b.bench(name="requires_bidi/\{name}", fn() {34      b.keep(@bidi.requires_bidi(input))35    })36    b.bench(name="process/\{name}", fn() { b.keep(@bidi.process(input)) })37  }38}39