unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

idna/idna_bench_test.mbt
1///|2/// Keep input validation outside the timed closures. Run with:3/// moon bench idna --target native --release4/// (also --target wasm and --target wasm-gc).5test "domain conversion" (b : @bench.T) {6  for7    (name, input) in [8      ("ASCII", "www.example.com"),9      ("long ASCII", "the-quick-brown-fox.jumps-over-the-lazy-dog.example.org"),10      ("mixed-case ASCII", "WWW.Example.COM"),11      ("ASCII underscore", "_dmarc.example.com"),12      ("Latin", "bücher.münchen.example"),13      ("mixed-case Latin", "Bücher.München.Example"),14      ("CJK", "例え.テスト.日本語"),15      ("Arabic", "مثال.إختبار"),16      ("A-labels", "xn--bcher-kva.xn--mnchen-3ya.example"),17    ] {18    // Every input is valid without STD3 rules, so the closures time19    // successful conversions only.20    ignore(@idna.to_ascii(input, use_std3_ascii_rules=false))21    ignore(@idna.to_unicode(input, use_std3_ascii_rules=false))22    b.bench(name="to_ascii/\{name}", fn() {23      b.keep(24        @idna.to_ascii(input, use_std3_ascii_rules=false) catch {25          _ => input26        },27      )28    })29    b.bench(name="to_unicode/\{name}", fn() {30      b.keep(31        @idna.to_unicode(input, use_std3_ascii_rules=false) catch {32          _ => input33        },34      )35    })36  }37}38