test: Added benchmark tests
This commit is contained in:
59
test/benchmark.gleam
Normal file
59
test/benchmark.gleam
Normal 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/"),
|
||||
],
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user