Closed inoas closed 1 year ago
Removed gleam_erlang and gleeunit deps already:
Closed in 0.2.0.
Now even in gleam_stdlib you can do:
gleam add glychee
gleam touch src/benchmark.gleam
paste:
if erlang {
import glychee/benchmark
import gleam/list
import gleam/int
pub fn main() {
benchmark.run(
[
benchmark.Function(
label: "list.sort()",
fun: fn(test_data) { fn() { list.sort(test_data, int.compare) } },
),
],
[
benchmark.Data(label: "pre-sorted list", data: list.range(1, 100_000)),
benchmark.Data(
label: "reversed list",
data: list.range(1, 100_000)
|> list.reverse,
),
],
)
}
}
run:
gleam clean && \
gleam build && \
erl -pa ./build/dev/erlang/*/ebin -noshell -eval 'gleam@@main:run(benchmark)'
Uses:
io.print
,io.println
,list.each
,list.map
Uses some more in the example file, which could be removed as well, the example can live on as documentation.
Once these are removed, glychee can be used to benchmark gleam_stdlib functions.