unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

ucd/case_mapping_bench_test.mbt
1///|2/// Keep input construction outside the timed closures. Run with:3/// moon bench ucd --target native --release4/// (also --target wasm and --target wasm-gc).5test "case mapping" (b : @bench.T) {6  for7    (name, input) in [8      ("ASCII", "Hello world, this is a Test. ".repeat(32)),9      ("Latin", "Ünïcödé Çàfé Straße ".repeat(32)),10      ("Greek", "Ὀδυσσεύς καὶ ᾈχιλλεύς ".repeat(32)),11      ("CJK", "世界こんにちは、テスト。".repeat(64)),12    ] {13    b.bench(name="to_simple_uppercase/\{name}", fn() {14      let mut sum = 015      for c in input {16        sum = sum ^ @ucd.to_simple_uppercase(c).to_int()17      }18      b.keep(sum)19    })20    b.bench(name="to_simple_lowercase/\{name}", fn() {21      let mut sum = 022      for c in input {23        sum = sum ^ @ucd.to_simple_lowercase(c).to_int()24      }25      b.keep(sum)26    })27    b.bench(name="to_uppercase/\{name}", fn() {28      let mut length = 029      for c in input {30        length += @ucd.to_uppercase(c).length()31      }32      b.keep(length)33    })34    b.bench(name="to_lowercase/\{name}", fn() {35      let mut length = 036      for c in input {37        length += @ucd.to_lowercase(c).length()38      }39      b.keep(length)40    })41  }42}43