test: Added benchmark tests

This commit is contained in:
2025-09-14 11:37:59 +01:00
parent e13f80c483
commit 91bfe0285f
3 changed files with 65 additions and 0 deletions

59
test/benchmark.gleam Normal file
View File

@@ -0,0 +1,59 @@
import gleam/uri as uri2
import gluri as uri
import gluri/internal/parser
import glychee/benchmark
import glychee/configuration
@target(erlang)
pub fn main() {
configuration.initialize()
configuration.set_pair(configuration.Warmup, 2)
configuration.set_pair(configuration.Parallel, 2)
parse_benchmark()
// reg_name_benchmark()
}
@target(erlang)
pub fn reg_name_benchmark() {
benchmark.run(
[
benchmark.Function("reg_name_benchmark", fn(data) {
fn() {
let _ = parser.parse_reg_name(data)
Nil
}
}),
],
[
benchmark.Data("long", "github.com"),
],
)
}
@target(erlang)
pub fn parse_benchmark() {
benchmark.run(
[
benchmark.Function("parse_benchmark", fn(data) {
fn() {
let _ = uri.parse(data)
Nil
}
}),
benchmark.Function("stdlib_parse_benchmark", fn(data) {
fn() {
let _ = uri2.parse(data)
Nil
}
}),
],
[
benchmark.Data(
"long",
"https://github.com/gleam-lang/stdlib/issues/523#issuecomment-3288230480",
),
benchmark.Data("ipv4", "https://192.255.36.4/"),
],
)
}