unicode

Branch: main

Switch branches or tags

Branch: main
Go to file t

413 files indexed

History
Code

idna/idna2008_bench_test.mbt
1///|2/// Benchmark the public conversion pipeline with both optional IDNA20083/// checks enabled. Inputs and their A-label forms are validated before timing.4/// Run with moon bench idna/idna2008_bench_test.mbt --target native --release5/// (also --target js, --target wasm-gc, and --target wasm).6test "IDNA2008 domain conversion" (b : @bench.T) {7  for8    (name, input) in [9      ("ASCII", "www.example.com"),10      ("Latin", "bücher.münchen.example"),11      ("middle dot", "l·l.example"),12      ("Greek", "\u{0375}α.example"),13      ("Hebrew", "א\u{05F3}.example"),14      ("Japanese early", "カ・abcdefghijklmnopqrstuvwx.example"),15      ("Japanese late", "abcdefghijklmnopqrstuvwx・カ.example"),16      ("Arabic digits", "ا١٢٣٤٥٦٧٨٩٠.example"),17      (18        "long middle dots", "l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l·l.example",19      ),20    ] {21    let ascii = @idna.to_ascii(input, check_idna2008=true, check_contexto=true)22    ignore(@idna.to_unicode(ascii, check_idna2008=true, check_contexto=true))23    b.bench(name="to_ascii/\{name}", fn() {24      b.keep(25        @idna.to_ascii(input, check_idna2008=true, check_contexto=true) catch {26          _ => input27        },28      )29    })30    b.bench(name="to_unicode/\{name}", fn() {31      b.keep(32        @idna.to_unicode(ascii, check_idna2008=true, check_contexto=true) catch {33          _ => ascii34        },35      )36    })37  }38}39