idna/idna_bench_test.mbt1///|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
///|
/// Keep input validation outside the timed closures. Run with:
/// moon bench idna --target native --release
/// (also --target wasm and --target wasm-gc).
test "domain conversion" (b : @bench.T) {
for
(name, input) in [
("ASCII", "www.example.com"),
("long ASCII", "the-quick-brown-fox.jumps-over-the-lazy-dog.example.org"),
("mixed-case ASCII", "WWW.Example.COM"),
("ASCII underscore", "_dmarc.example.com"),
("Latin", "bücher.münchen.example"),
("mixed-case Latin", "Bücher.München.Example"),
("CJK", "例え.テスト.日本語"),
("Arabic", "مثال.إختبار"),
("A-labels", "xn--bcher-kva.xn--mnchen-3ya.example"),
] {
// Every input is valid without STD3 rules, so the closures time
// successful conversions only.
ignore(@idna.to_ascii(input, use_std3_ascii_rules=false))
ignore(@idna.to_unicode(input, use_std3_ascii_rules=false))
b.bench(name="to_ascii/\{name}", fn() {
b.keep(
@idna.to_ascii(input, use_std3_ascii_rules=false) catch {
_ => input
},
)
})
b.bench(name="to_unicode/\{name}", fn() {
b.keep(
@idna.to_unicode(input, use_std3_ascii_rules=false) catch {
_ => input
},
)
})
}
}