test: Added benchmark test

This commit is contained in:
2025-11-04 13:56:55 +00:00
parent 6634406a78
commit 7793bbb3a3
3 changed files with 57 additions and 1 deletions

46
dev/benchmark.gleam Normal file
View File

@@ -0,0 +1,46 @@
import gleam/list
import glychee/benchmark
import glychee/configuration
import lancaster_stemmer
import porter_stemmer
@target(erlang)
pub fn main() {
configuration.initialize()
configuration.set_pair(configuration.Warmup, 2)
configuration.set_pair(configuration.Parallel, 2)
// pop_benchmark()
benchmark()
// reg_name_benchmark()
// ip_benchmark()
}
@target(erlang)
fn benchmark() {
let rules = lancaster_stemmer.default_rules()
benchmark.run(
[
benchmark.Function("Lancaster", fn(data) {
fn() { list.each(data, lancaster_stemmer.stem(_, rules)) }
}),
benchmark.Function("Porter", fn(data) {
fn() { list.each(data, porter_stemmer.stem) }
}),
],
[
benchmark.Data("10 words", [
"abbreviate",
"aberdeen",
"abode",
"abovementioned",
"absent",
"adherent",
"adhesion",
"adhesive",
"adiabatic",
"anisotropic",
]),
],
)
}