@@ -15,10 +15,12 @@ Named after *Gleam*, *Benchee* and their fruity [*Lychee*](https://en.wikipedia.
15
15
16
16
## Requirements
17
17
18
- - Requires Gleam 0.30 or later.
18
+ - Requires ** Gleam 1.0** or later.
19
+ - For benchmarking on target JavaScript see < https://hex.pm/packages/gleamy_bench > ,
20
+ as Glychee only allows benchmarking on target Erlang.
21
+ - Glychee is dependency free except for * Benchee* and * Elixir* .
19
22
- A recent Elixir and Hex must be installed. You might be required to run
20
23
` mix local.hex ` after installing Elixir.
21
- - Only allows benchmarking of target Erlang and not target JavaScript.
22
24
23
25
## Quick start
24
26
@@ -28,68 +30,57 @@ Named after *Gleam*, *Benchee* and their fruity [*Lychee*](https://en.wikipedia.
28
30
to benchmark with one or many ` Data ` .
29
31
3 . Run the benchmark:
30
32
31
- ``` sh
33
+ ``` shell
32
34
gleam clean && \
33
35
gleam build && \
34
- erl -pa ./build/dev/erlang/ * /ebin -noshell -eval ' PROJECT_NAME@@main:run( my_benchmark) '
36
+ gleam run -m my_benchmark
35
37
```
36
38
37
- ... where ` PROJECT_NAME ` is set via the root level ` name ` property in ` gleam.toml ` .
38
-
39
39
### Full example
40
40
41
41
If you do not have a Gleam project yet, create it with:
42
42
43
- ``` sh
43
+ ``` shell
44
44
gleam new foobar
45
45
cd foobar
46
46
```
47
47
48
- Add ** Glychee** : ` gleam add glychee --dev ` , then in your project create a file named
49
- ` src/benchmark.gleam ` with following source code:
50
-
51
- ``` gleam
52
- if erlang {
53
- import gleam/int
54
- import gleam/list
55
- import glychee/benchmark
56
-
57
- pub fn main() {
58
- benchmark.run(
59
- [
60
- benchmark.Function(
61
- label: "list.sort()",
62
- callable: fn(test_data) {
63
- fn() {
64
- list.sort(test_data, int.compare)
65
- }
66
- },
67
- ),
68
- ],
69
- [
70
- benchmark.Data(
71
- label: "pre-sorted list",
72
- data: list.range(1, 100_000),
73
- ),
74
- benchmark.Data(
75
- label: "reversed list",
76
- data: list.range(1, 100_000) |> list.reverse,
77
- ),
78
- ],
79
- )
80
- }
81
- }
82
- ```
83
-
84
- Then run in your terminal via:
48
+ To add and run a demo of ** Glychee** :
49
+
50
+ 1 . ` gleam add glychee --dev `
51
+ 2 . In your project create a file named ` src/my_benchmark.gleam ` with following source code:
52
+
53
+ ``` gleam
54
+ import gleam/int
55
+ import gleam/list
56
+ import glychee/benchmark
57
+
58
+ pub fn main() {
59
+ benchmark.run(
60
+ [
61
+ benchmark.Function(label: "list.sort()", callable: fn(test_data) {
62
+ fn() { list.sort(test_data, int.compare) }
63
+ }),
64
+ ],
65
+ [
66
+ benchmark.Data(label: "pre-sorted list", data: list.range(1, 100_000)),
67
+ benchmark.Data(
68
+ label: "reversed list",
69
+ data: list.range(1, 100_000)
70
+ |> list.reverse,
71
+ ),
72
+ ],
73
+ )
74
+ }
75
+ ```
85
76
86
- ``` sh
87
- gleam clean && \
88
- gleam build && \
89
- erl -pa ./build/dev/erlang/* /ebin -noshell -eval ' PROJECT_NAME@@main:run(benchmark)'
90
- ```
77
+ 3 . Then run in your terminal via:
91
78
92
- ... where ` PROJECT_NAME ` is set via the root level ` name ` property in ` gleam.toml ` .
79
+ ``` shell
80
+ gleam clean && \
81
+ gleam build && \
82
+ gleam run -m my_benchmark
83
+ ```
93
84
94
85
Now you can alter the functions and data specified in above's example to
95
86
whichever function of your application or library you want to benchmark.
0 commit comments