Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inoas/glychee
Glychee: Easy access to Elixir's benchee in Gleam
https://github.com/inoas/glychee
Last synced: 3 months ago
JSON representation
Glychee: Easy access to Elixir's benchee in Gleam
- Host: GitHub
- URL: https://github.com/inoas/glychee
- Owner: inoas
- License: apache-2.0
- Created: 2022-10-20T22:21:59.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-06T17:24:22.000Z (5 months ago)
- Last Synced: 2024-07-18T12:05:16.299Z (4 months ago)
- Language: Gleam
- Homepage: https://hexdocs.pm/glychee
- Size: 368 KB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gleam - inoas/glychee - A simple Gleam benchmark runner which wraps Benchee for the heavy lifting. (Tools / Web applications)
README
# Glychee Benchmark · Simple Gleam Benchmarking on Erlang via Elixir's Benchee
[![Hex Package](https://img.shields.io/hexpm/v/glychee?color=ffaff3&label=%F0%9F%93%A6)](https://hex.pm/packages/glychee)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3?label=%F0%9F%93%9A)](https://hexdocs.pm/glychee/)
[![License](https://img.shields.io/hexpm/l/glychee?color=ffaff3&label=%F0%9F%93%83)](https://github.com/inoas/glychee/blob/main/LICENSE)A simple [Gleam](https://gleam.run) benchmark runner which wraps [**Benchee**](https://github.com/bencheeorg/benchee) for the heavy lifting.
Named after _Gleam_, _Benchee_ and their fruity [_Lychee_](https://en.wikipedia.org/wiki/Lychee) offspring:
Imaginary Glychees## Requirements
- Requires **Gleam 1.0** or later.
- For benchmarking on target JavaScript see ,
as Glychee only allows benchmarking on target Erlang.
- Glychee is dependency free except for _Benchee_ and _Elixir_.
- A recent Elixir and Hex must be installed. You might be required to run
`mix local.hex` after installing Elixir.## Quick start
1. Add **_Glychee_** to your project: `gleam add glychee --dev`.
2. Create a custom benchmarking module for example named `my_benchmark` that
contains a `main`-function. In that module you will define which `Function`s
to benchmark with one or many `Data`.
3. Run the benchmark:```shell
gleam clean && \
gleam build && \
gleam run -m my_benchmark
```### Full example
If you do not have a Gleam project yet, create it with:
```shell
gleam new foobar
cd foobar
```To add and run a demo of **Glychee**:
1. `gleam add glychee --dev`
2. In your project create a file named `src/my_benchmark.gleam` with following source code:```gleam
import gleam/int
import gleam/list
import glychee/benchmark
import glychee/configuration
pub fn main() {
// Configuration is optional
configuration.initialize()
configuration.set_pair(configuration.Warmup, 2)
configuration.set_pair(configuration.Parallel, 2)
// Run the benchmarks
benchmark.run(
[
benchmark.Function(label: "list.sort()", callable: 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,
),
],
)
}
```3. Then run in your terminal via:
```shell
gleam clean && \
gleam build && \
gleam run -m my_benchmark
```Now you can alter the functions and data specified in above's example to
whichever function of your application or library you want to benchmark.Note that you can benchmark multiple functions with different data sets
in one go.## Documentation
**Glychee**'s documentation can be found at .
## License
[Apache 2.0](./LICENSE)