changed .formatter.exs
 
@@ -1,4 +1,5 @@
1
1
# Used by "mix format"
2
2
[
3
+ plugins: [DoctestFormatter],
3
4
inputs: ["{mix,.formatter}.exs", "{config,lib,test,samples,mix}/**/*.{ex,exs}"]
4
5
]
changed CHANGELOG.md
 
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+ ## 1.3.1 (2024-06-05)
9
+
10
+ Small release to remove warnings for the upcoming elixir 1.17 as well as add proper solaris support.
11
+
12
+ ### Features (User Facing)
13
+ * Solaris systems will now correctly be identified and have their CPU and memory parsed. Thanks to [@brianewell](https://github.com/brianewell)!
14
+
15
+ ### Bugfixes (User Facing)
16
+ * warnings on elixir-main/1.17-rc have been removed. Thanks to [@mhanberg](https://github.com/mhanberg) & [@alco](https://github.com/alco)!
17
+
8
18
## 1.3.0 (2023-12-22)
9
19
A big swath of bug fixes and improvements. The highlights certainly are fixes and conveniences around saved benchmarks and loading them again via the new `Benchee.report/1`. The other big one is saving a lot of memory (and time!) when processing big inputs. Sadly the latter comes with some breaking changes for plugins, but they are well justified and shouldn't actually affect any plugin in practice.
changed hex_metadata.config
 
@@ -3,7 +3,7 @@
3
3
{<<"Changelog">>,<<"https://hexdocs.pm/benchee/changelog.html">>},
4
4
{<<"GitHub">>,<<"https://github.com/bencheeorg/benchee">>}]}.
5
5
{<<"name">>,<<"benchee">>}.
6
- {<<"version">>,<<"1.3.0">>}.
6
+ {<<"version">>,<<"1.3.1">>}.
7
7
{<<"description">>,
8
8
<<"Versatile (micro) benchmarking that is extensible. Get statistics such as:\naverage, iterations per second, standard deviation and the median.">>}.
9
9
{<<"elixir">>,<<"~> 1.6">>}.
changed lib/benchee/configuration.ex
 
@@ -181,58 +181,56 @@ defmodule Benchee.Configuration do
181
181
182
182
iex> init()
183
183
%Benchee.Suite{
184
- configuration:
185
- %Benchee.Configuration{
186
- parallel: 1,
187
- time: 5_000_000_000.0,
188
- warmup: 2_000_000_000.0,
189
- inputs: nil,
190
- input_names: [],
191
- save: false,
192
- load: false,
193
- formatters: [Benchee.Formatters.Console],
194
- print: %{
195
- benchmarking: true,
196
- fast_warning: true,
197
- configuration: true
198
- },
199
- percentiles: [50, 99],
200
- unit_scaling: :best,
201
- assigns: %{},
202
- before_each: nil,
203
- after_each: nil,
204
- before_scenario: nil,
205
- after_scenario: nil
184
+ configuration: %Benchee.Configuration{
185
+ parallel: 1,
186
+ time: 5_000_000_000.0,
187
+ warmup: 2_000_000_000.0,
188
+ inputs: nil,
189
+ input_names: [],
190
+ save: false,
191
+ load: false,
192
+ formatters: [Benchee.Formatters.Console],
193
+ print: %{
194
+ benchmarking: true,
195
+ fast_warning: true,
196
+ configuration: true
206
197
},
198
+ percentiles: [50, 99],
199
+ unit_scaling: :best,
200
+ assigns: %{},
201
+ before_each: nil,
202
+ after_each: nil,
203
+ before_scenario: nil,
204
+ after_scenario: nil
205
+ },
207
206
system: nil,
208
207
scenarios: []
209
208
}
210
209
211
210
iex> init(time: 1, warmup: 0.2)
212
211
%Benchee.Suite{
213
- configuration:
214
- %Benchee.Configuration{
215
- parallel: 1,
216
- time: 1_000_000_000.0,
217
- warmup: 200_000_000.0,
218
- inputs: nil,
219
- input_names: [],
220
- save: false,
221
- load: false,
222
- formatters: [Benchee.Formatters.Console],
223
- print: %{
224
- benchmarking: true,
225
- fast_warning: true,
226
- configuration: true
227
- },
228
- percentiles: [50, 99],
229
- unit_scaling: :best,
230
- assigns: %{},
231
- before_each: nil,
232
- after_each: nil,
233
- before_scenario: nil,
234
- after_scenario: nil
212
+ configuration: %Benchee.Configuration{
213
+ parallel: 1,
214
+ time: 1_000_000_000.0,
215
+ warmup: 200_000_000.0,
216
+ inputs: nil,
217
+ input_names: [],
218
+ save: false,
219
+ load: false,
220
+ formatters: [Benchee.Formatters.Console],
221
+ print: %{
222
+ benchmarking: true,
223
+ fast_warning: true,
224
+ configuration: true
235
225
},
226
+ percentiles: [50, 99],
227
+ unit_scaling: :best,
228
+ assigns: %{},
229
+ before_each: nil,
230
+ after_each: nil,
231
+ before_scenario: nil,
232
+ after_scenario: nil
233
+ },
236
234
system: nil,
237
235
scenarios: []
238
236
}
 
@@ -244,31 +242,31 @@ defmodule Benchee.Configuration do
244
242
...> formatters: [&IO.puts/1],
245
243
...> print: [fast_warning: false],
246
244
...> inputs: %{"Small" => 5, "Big" => 9999},
247
- ...> unit_scaling: :smallest)
245
+ ...> unit_scaling: :smallest
246
+ ...> )
248
247
%Benchee.Suite{
249
- configuration:
250
- %Benchee.Configuration{
251
- parallel: 2,
252
- time: 1_000_000_000.0,
253
- warmup: 200_000_000.0,
254
- inputs: [{"Big", 9999}, {"Small", 5}],
255
- input_names: ["Big", "Small"],
256
- save: false,
257
- load: false,
258
- formatters: [&IO.puts/1],
259
- print: %{
260
- benchmarking: true,
261
- fast_warning: false,
262
- configuration: true
263
- },
264
- percentiles: [50, 99],
265
- unit_scaling: :smallest,
266
- assigns: %{},
267
- before_each: nil,
268
- after_each: nil,
269
- before_scenario: nil,
270
- after_scenario: nil
248
+ configuration: %Benchee.Configuration{
249
+ parallel: 2,
250
+ time: 1_000_000_000.0,
251
+ warmup: 200_000_000.0,
252
+ inputs: [{"Big", 9999}, {"Small", 5}],
253
+ input_names: ["Big", "Small"],
254
+ save: false,
255
+ load: false,
256
+ formatters: [&IO.puts/1],
257
+ print: %{
258
+ benchmarking: true,
259
+ fast_warning: false,
260
+ configuration: true
271
261
},
262
+ percentiles: [50, 99],
263
+ unit_scaling: :smallest,
264
+ assigns: %{},
265
+ before_each: nil,
266
+ after_each: nil,
267
+ before_scenario: nil,
268
+ after_scenario: nil
269
+ },
272
270
system: nil,
273
271
scenarios: []
274
272
}
changed lib/benchee/conversion.ex
 
@@ -18,37 +18,39 @@ defmodule Benchee.Conversion do
18
18
## Examples
19
19
20
20
iex> statistics = %Benchee.Statistics{average: 1_000_000.0, ips: 1000.0}
21
- iex> scenario = %Benchee.Scenario{
21
+ ...>
22
+ ...> scenario = %Benchee.Scenario{
22
23
...> run_time_data: %Benchee.CollectionData{statistics: statistics},
23
24
...> memory_usage_data: %Benchee.CollectionData{statistics: statistics},
24
25
...> reductions_data: %Benchee.CollectionData{statistics: statistics}
25
26
...> }
26
- iex> Benchee.Conversion.units([scenario], :best)
27
+ ...>
28
+ ...> Benchee.Conversion.units([scenario], :best)
27
29
%{
28
- ips: %Benchee.Conversion.Unit{
29
- label: "K",
30
- long: "Thousand",
31
- magnitude: 1000,
32
- name: :thousand
33
- },
34
- run_time: %Benchee.Conversion.Unit{
35
- label: "ms",
36
- long: "Milliseconds",
37
- magnitude: 1_000_000,
38
- name: :millisecond
39
- },
40
- memory: %Benchee.Conversion.Unit{
41
- label: "KB",
42
- long: "Kilobytes",
43
- magnitude: 1024,
44
- name: :kilobyte
45
- },
30
+ ips: %Benchee.Conversion.Unit{
31
+ label: "K",
32
+ long: "Thousand",
33
+ magnitude: 1000,
34
+ name: :thousand
35
+ },
36
+ run_time: %Benchee.Conversion.Unit{
37
+ label: "ms",
38
+ long: "Milliseconds",
39
+ magnitude: 1_000_000,
40
+ name: :millisecond
41
+ },
42
+ memory: %Benchee.Conversion.Unit{
43
+ label: "KB",
44
+ long: "Kilobytes",
45
+ magnitude: 1024,
46
+ name: :kilobyte
47
+ },
46
48
reduction_count: %Benchee.Conversion.Unit{
47
- label: "M",
48
- long: "Million",
49
- magnitude: 1000000,
50
- name: :million
51
- }
49
+ label: "M",
50
+ long: "Million",
51
+ magnitude: 1_000_000,
52
+ name: :million
53
+ }
52
54
}
53
55
"""
54
56
def units(scenarios, scaling_strategy) do
changed lib/benchee/conversion/count.ex
 
@@ -52,13 +52,13 @@ defmodule Benchee.Conversion.Count do
52
52
## Examples
53
53
54
54
iex> {value, unit} = scale(4_321.09)
55
- iex> value
55
+ ...> value
56
56
4.32109
57
57
iex> unit.name
58
58
:thousand
59
59
60
60
iex> {value, unit} = scale(0.0045)
61
- iex> value
61
+ ...> value
62
62
0.0045
63
63
iex> unit.name
64
64
:one
 
@@ -91,25 +91,25 @@ defmodule Benchee.Conversion.Count do
91
91
92
92
## Examples
93
93
94
- iex> unit_for :thousand
94
+ iex> unit_for(:thousand)
95
95
%Benchee.Conversion.Unit{
96
- name: :thousand,
96
+ name: :thousand,
97
97
magnitude: 1_000,
98
- label: "K",
99
- long: "Thousand"
98
+ label: "K",
99
+ long: "Thousand"
100
100
}
101
101
102
102
iex> unit_for(%Benchee.Conversion.Unit{
103
- ...> name: :thousand,
103
+ ...> name: :thousand,
104
104
...> magnitude: 1_000,
105
- ...> label: "K",
106
- ...> long: "Thousand"
107
- ...>})
105
+ ...> label: "K",
106
+ ...> long: "Thousand"
107
+ ...> })
108
108
%Benchee.Conversion.Unit{
109
- name: :thousand,
109
+ name: :thousand,
110
110
magnitude: 1_000,
111
- label: "K",
112
- long: "Thousand"
111
+ label: "K",
112
+ long: "Thousand"
113
113
}
114
114
"""
115
115
def unit_for(unit) do
 
@@ -148,7 +148,7 @@ defmodule Benchee.Conversion.Count do
148
148
## Examples
149
149
150
150
iex> {value, unit} = convert({2500, :thousand}, :million)
151
- iex> value
151
+ ...> value
152
152
2.5
153
153
iex> unit.name
154
154
:million
 
@@ -212,7 +212,9 @@ defmodule Benchee.Conversion.Count do
212
212
iex> format({45.6789, :thousand})
213
213
"45.68 K"
214
214
215
- iex> format({45.6789, %Benchee.Conversion.Unit{long: "Thousand", magnitude: "1_000", label: "K"}})
215
+ iex> format(
216
+ ...> {45.6789, %Benchee.Conversion.Unit{long: "Thousand", magnitude: "1_000", label: "K"}}
217
+ ...> )
216
218
"45.68 K"
217
219
"""
218
220
def format(count) do
changed lib/benchee/conversion/duration.ex
 
@@ -68,19 +68,19 @@ defmodule Benchee.Conversion.Duration do
68
68
## Examples
69
69
70
70
iex> {value, unit} = scale(1)
71
- iex> value
71
+ ...> value
72
72
1.0
73
73
iex> unit.name
74
74
:nanosecond
75
75
76
76
iex> {value, unit} = scale(1_234)
77
- iex> value
77
+ ...> value
78
78
1.234
79
79
iex> unit.name
80
80
:microsecond
81
81
82
82
iex> {value, unit} = scale(11_234_567_890_123)
83
- iex> value
83
+ ...> value
84
84
3.1207133028119443
85
85
iex> unit.name
86
86
:hour
 
@@ -120,25 +120,25 @@ defmodule Benchee.Conversion.Duration do
120
120
121
121
## Examples
122
122
123
- iex> unit_for :hour
123
+ iex> unit_for(:hour)
124
124
%Benchee.Conversion.Unit{
125
- name: :hour,
125
+ name: :hour,
126
126
magnitude: 3_600_000_000_000,
127
- label: "h",
128
- long: "Hours"
127
+ label: "h",
128
+ long: "Hours"
129
129
}
130
130
131
131
iex> unit_for(%Benchee.Conversion.Unit{
132
- ...> name: :hour,
132
+ ...> name: :hour,
133
133
...> magnitude: 3_600_000_000_000,
134
- ...> label: "h",
135
- ...> long: "Hours"
136
- ...>})
134
+ ...> label: "h",
135
+ ...> long: "Hours"
136
+ ...> })
137
137
%Benchee.Conversion.Unit{
138
- name: :hour,
138
+ name: :hour,
139
139
magnitude: 3_600_000_000_000,
140
- label: "h",
141
- long: "Hours"
140
+ label: "h",
141
+ long: "Hours"
142
142
}
143
143
"""
144
144
def unit_for(unit) do
 
@@ -174,7 +174,7 @@ defmodule Benchee.Conversion.Duration do
174
174
## Examples
175
175
176
176
iex> {value, unit} = convert({90, :minute}, :hour)
177
- iex> value
177
+ ...> value
178
178
1.5
179
179
iex> unit.name
180
180
:hour
 
@@ -195,8 +195,8 @@ defmodule Benchee.Conversion.Duration do
195
195
7.404e7
196
196
197
197
iex> microseconds = convert_value({1.234, :minute}, :microsecond)
198
- iex> {value, _} = convert({microseconds, :microsecond}, :minute)
199
- iex> value
198
+ ...> {value, _} = convert({microseconds, :microsecond}, :minute)
199
+ ...> value
200
200
1.234
201
201
202
202
"""
 
@@ -258,10 +258,14 @@ defmodule Benchee.Conversion.Duration do
258
258
iex> format({45.6789, :millisecond})
259
259
"45.68 ms"
260
260
261
- iex> format {45.6789,
262
- ...> %Benchee.Conversion.Unit{
263
- ...> long: "Milliseconds", magnitude: 1000, label: "ms"}
264
- ...> }
261
+ iex> format(
262
+ ...> {45.6789,
263
+ ...> %Benchee.Conversion.Unit{
264
+ ...> long: "Milliseconds",
265
+ ...> magnitude: 1000,
266
+ ...> label: "ms"
267
+ ...> }}
268
+ ...> )
265
269
"45.68 ms"
266
270
267
271
"""
changed lib/benchee/conversion/memory.ex
 
@@ -59,14 +59,14 @@ defmodule Benchee.Conversion.Memory do
59
59
## Examples
60
60
61
61
iex> {value, unit} = convert({1024, :kilobyte}, :megabyte)
62
- iex> value
62
+ ...> value
63
63
1.0
64
64
iex> unit.name
65
65
:megabyte
66
66
67
- iex> current_unit = unit_for :kilobyte
68
- iex> {value, unit} = convert({1024, current_unit}, :megabyte)
69
- iex> value
67
+ iex> current_unit = unit_for(:kilobyte)
68
+ ...> {value, unit} = convert({1024, current_unit}, :megabyte)
69
+ ...> value
70
70
1.0
71
71
iex> unit.name
72
72
:megabyte
 
@@ -84,25 +84,25 @@ defmodule Benchee.Conversion.Memory do
84
84
## Examples
85
85
86
86
iex> {value, unit} = scale(1)
87
- iex> value
87
+ ...> value
88
88
1.0
89
89
iex> unit.name
90
90
:byte
91
91
92
92
iex> {value, unit} = scale(1_234)
93
- iex> value
93
+ ...> value
94
94
1.205078125
95
95
iex> unit.name
96
96
:kilobyte
97
97
98
98
iex> {value, unit} = scale(11_234_567_890.123)
99
- iex> value
99
+ ...> value
100
100
10.463006692121736
101
101
iex> unit.name
102
102
:gigabyte
103
103
104
104
iex> {value, unit} = scale(1_111_234_567_890.123)
105
- iex> value
105
+ ...> value
106
106
1.0106619519229962
107
107
iex> unit.name
108
108
:terabyte
 
@@ -142,25 +142,25 @@ defmodule Benchee.Conversion.Memory do
142
142
143
143
## Examples
144
144
145
- iex> unit_for :gigabyte
145
+ iex> unit_for(:gigabyte)
146
146
%Benchee.Conversion.Unit{
147
- name: :gigabyte,
148
- magnitude: 1_073_741_824,
149
- label: "GB",
150
- long: "Gigabytes"
147
+ name: :gigabyte,
148
+ magnitude: 1_073_741_824,
149
+ label: "GB",
150
+ long: "Gigabytes"
151
151
}
152
152
153
153
iex> unit_for(%Benchee.Conversion.Unit{
154
- ...> name: :gigabyte,
154
+ ...> name: :gigabyte,
155
155
...> magnitude: 1_073_741_824,
156
- ...> label: "GB",
157
- ...> long: "Gigabytes"
158
- ...>})
156
+ ...> label: "GB",
157
+ ...> long: "Gigabytes"
158
+ ...> })
159
159
%Benchee.Conversion.Unit{
160
- name: :gigabyte,
161
- magnitude: 1_073_741_824,
162
- label: "GB",
163
- long: "Gigabytes"
160
+ name: :gigabyte,
161
+ magnitude: 1_073_741_824,
162
+ label: "GB",
163
+ long: "Gigabytes"
164
164
}
165
165
"""
166
166
def unit_for(unit) do
 
@@ -246,10 +246,14 @@ defmodule Benchee.Conversion.Memory do
246
246
iex> format({45.6789, :kilobyte})
247
247
"45.68 KB"
248
248
249
- iex> format {45.6789,
250
- ...> %Benchee.Conversion.Unit{
251
- ...> long: "Kilobytes", magnitude: 1024, label: "KB"}
252
- ...> }
249
+ iex> format(
250
+ ...> {45.6789,
251
+ ...> %Benchee.Conversion.Unit{
252
+ ...> long: "Kilobytes",
253
+ ...> magnitude: 1024,
254
+ ...> label: "KB"
255
+ ...> }}
256
+ ...> )
253
257
"45.68 KB"
254
258
255
259
"""
changed lib/benchee/conversion/scale.ex
 
@@ -83,7 +83,7 @@ defmodule Benchee.Conversion.Scale do
83
83
## Examples
84
84
85
85
iex> unit = %Benchee.Conversion.Unit{magnitude: 1000}
86
- iex> scale 12345, unit
86
+ ...> scale(12345, unit)
87
87
12.345
88
88
"""
89
89
def scale(value, %Unit{magnitude: magnitude}) do
 
@@ -135,31 +135,31 @@ defmodule Benchee.Conversion.Scale do
135
135
## Examples
136
136
137
137
iex> list = [1, 101, 1_001, 10_001, 100_001, 1_000_001]
138
- iex> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
138
+ ...> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
139
139
:thousand
140
140
141
141
iex> list = [1, 101, 1_001, 10_001, 100_001, 1_000_001]
142
- iex> best_unit(list, Benchee.Conversion.Count, strategy: :smallest).name
142
+ ...> best_unit(list, Benchee.Conversion.Count, strategy: :smallest).name
143
143
:one
144
144
145
145
iex> list = [1, 101, 1_001, 10_001, 100_001, 1_000_001]
146
- iex> best_unit(list, Benchee.Conversion.Count, strategy: :largest).name
146
+ ...> best_unit(list, Benchee.Conversion.Count, strategy: :largest).name
147
147
:million
148
148
149
149
iex> list = []
150
- iex> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
150
+ ...> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
151
151
:one
152
152
153
153
iex> list = [nil]
154
- iex> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
154
+ ...> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
155
155
:one
156
156
157
157
iex> list = [nil, nil, nil, nil]
158
- iex> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
158
+ ...> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
159
159
:one
160
160
161
161
iex> list = [nil, nil, nil, nil, 2_000]
162
- iex> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
162
+ ...> best_unit(list, Benchee.Conversion.Count, strategy: :best).name
163
163
:thousand
164
164
"""
165
165
def best_unit(measurements, module, options) do
 
@@ -167,7 +167,7 @@ defmodule Benchee.Conversion.Scale do
167
167
end
168
168
169
169
defp do_best_unit([], module, _) do
170
- module.base_unit
170
+ module.base_unit()
171
171
end
172
172
173
173
defp do_best_unit(list, module, opts) do
 
@@ -175,7 +175,7 @@ defmodule Benchee.Conversion.Scale do
175
175
:best -> best_unit(list, module)
176
176
:largest -> largest_unit(list, module)
177
177
:smallest -> smallest_unit(list, module)
178
- :none -> module.base_unit
178
+ :none -> module.base_unit()
179
179
end
180
180
end
changed lib/benchee/formatters/console.ex
 
@@ -48,7 +48,9 @@ defmodule Benchee.Formatters.Console do
48
48
```
49
49
iex> scenarios = [
50
50
...> %Benchee.Scenario{
51
- ...> name: "My Job", input_name: "My input", run_time_data: %Benchee.CollectionData{
51
+ ...> name: "My Job",
52
+ ...> input_name: "My input",
53
+ ...> run_time_data: %Benchee.CollectionData{
52
54
...> statistics: %Benchee.Statistics{
53
55
...> average: 200.0,
54
56
...> ips: 5000.0,
 
@@ -61,7 +63,9 @@ defmodule Benchee.Formatters.Console do
61
63
...> memory_usage_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{}}
62
64
...> },
63
65
...> %Benchee.Scenario{
64
- ...> name: "Job 2", input_name: "My input", run_time_data: %Benchee.CollectionData{
66
+ ...> name: "Job 2",
67
+ ...> input_name: "My input",
68
+ ...> run_time_data: %Benchee.CollectionData{
65
69
...> statistics: %Benchee.Statistics{
66
70
...> average: 400.0,
67
71
...> ips: 2500.0,
 
@@ -74,16 +78,23 @@ defmodule Benchee.Formatters.Console do
74
78
...> memory_usage_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{}}
75
79
...> }
76
80
...> ]
77
- iex> suite = %Benchee.Suite{
81
+ ...>
82
+ ...> suite = %Benchee.Suite{
78
83
...> scenarios: scenarios,
79
84
...> configuration: %Benchee.Configuration{
80
- ...> unit_scaling: :best,
85
+ ...> unit_scaling: :best
81
86
...> }
82
87
...> }
83
- iex> format(suite, %{comparison: false, extended_statistics: false})
84
- [["\n##### With input My input #####", "\nName ips average deviation median 99th %\n",
85
- "My Job 5 K 200 ns ±10.00% 190 ns 300.10 ns\n",
86
- "Job 2 2.50 K 400 ns ±20.00% 390 ns 500.10 ns\n"]]
88
+ ...>
89
+ ...> format(suite, %{comparison: false, extended_statistics: false})
90
+ [
91
+ [
92
+ "\n##### With input My input #####",
93
+ "\nName ips average deviation median 99th %\n",
94
+ "My Job 5 K 200 ns ±10.00% 190 ns 300.10 ns\n",
95
+ "Job 2 2.50 K 400 ns ±20.00% 390 ns 500.10 ns\n"
96
+ ]
97
+ ]
87
98
88
99
```
changed lib/benchee/formatters/console/run_time.ex
 
@@ -35,14 +35,22 @@ defmodule Benchee.Formatters.Console.RunTime do
35
35
36
36
```
37
37
iex> memory_statistics = %Benchee.Statistics{average: 100.0}
38
- iex> scenarios = [
38
+ ...>
39
+ ...> scenarios = [
39
40
...> %Benchee.Scenario{
40
41
...> name: "My Job",
41
42
...> run_time_data: %Benchee.CollectionData{
42
43
...> statistics: %Benchee.Statistics{
43
- ...> average: 200.0, ips: 5000.0,std_dev_ratio: 0.1, median: 190.0, percentiles: %{99 => 300.1},
44
- ...> minimum: 100.1, maximum: 200.2, sample_size: 10_101, mode: 333.2
45
- ...> },
44
+ ...> average: 200.0,
45
+ ...> ips: 5000.0,
46
+ ...> std_dev_ratio: 0.1,
47
+ ...> median: 190.0,
48
+ ...> percentiles: %{99 => 300.1},
49
+ ...> minimum: 100.1,
50
+ ...> maximum: 200.2,
51
+ ...> sample_size: 10_101,
52
+ ...> mode: 333.2
53
+ ...> }
46
54
...> },
47
55
...> memory_usage_data: %Benchee.CollectionData{statistics: memory_statistics}
48
56
...> },
 
@@ -50,22 +58,32 @@ defmodule Benchee.Formatters.Console.RunTime do
50
58
...> name: "Job 2",
51
59
...> run_time_data: %Benchee.CollectionData{
52
60
...> statistics: %Benchee.Statistics{
53
- ...> average: 400.0, ips: 2500.0, std_dev_ratio: 0.2, median: 390.0, percentiles: %{99 => 500.1},
54
- ...> minimum: 200.2, maximum: 400.4, sample_size: 20_202, mode: [612.3, 554.1]
61
+ ...> average: 400.0,
62
+ ...> ips: 2500.0,
63
+ ...> std_dev_ratio: 0.2,
64
+ ...> median: 390.0,
65
+ ...> percentiles: %{99 => 500.1},
66
+ ...> minimum: 200.2,
67
+ ...> maximum: 400.4,
68
+ ...> sample_size: 20_202,
69
+ ...> mode: [612.3, 554.1]
55
70
...> }
56
71
...> },
57
72
...> memory_usage_data: %Benchee.CollectionData{statistics: memory_statistics}
58
73
...> }
59
74
...> ]
60
- iex> configuration = %{comparison: false, unit_scaling: :best, extended_statistics: true}
61
- iex> format_scenarios(scenarios, configuration)
62
- ["\nName ips average deviation median 99th %\n",
63
- "My Job 5 K 200 ns ±10.00% 190 ns 300.10 ns\n",
64
- "Job 2 2.50 K 400 ns ±20.00% 390 ns 500.10 ns\n",
65
- "\nExtended statistics: \n",
66
- "\nName minimum maximum sample size mode\n",
67
- "My Job 100.10 ns 200.20 ns 10.10 K 333.20 ns\n",
68
- "Job 2 200.20 ns 400.40 ns 20.20 K 612.30 ns, 554.10 ns\n"]
75
+ ...>
76
+ ...> configuration = %{comparison: false, unit_scaling: :best, extended_statistics: true}
77
+ ...> format_scenarios(scenarios, configuration)
78
+ [
79
+ "\nName ips average deviation median 99th %\n",
80
+ "My Job 5 K 200 ns ±10.00% 190 ns 300.10 ns\n",
81
+ "Job 2 2.50 K 400 ns ±20.00% 390 ns 500.10 ns\n",
82
+ "\nExtended statistics: \n",
83
+ "\nName minimum maximum sample size mode\n",
84
+ "My Job 100.10 ns 200.20 ns 10.10 K 333.20 ns\n",
85
+ "Job 2 200.20 ns 400.40 ns 20.20 K 612.30 ns, 554.10 ns\n"
86
+ ]
69
87
70
88
```
changed lib/benchee/scenario.ex
 
@@ -113,16 +113,29 @@ defmodule Benchee.Scenario do
113
113
114
114
## Examples
115
115
116
- iex> scenario = %Benchee.Scenario{run_time_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 1}}}
117
- iex> measurement_data(scenario, :run_time)
116
+ iex> scenario = %Benchee.Scenario{
117
+ ...> run_time_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 1}}
118
+ ...> }
119
+ ...>
120
+ ...> measurement_data(scenario, :run_time)
118
121
%Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 1}}
119
122
120
- iex> scenario = %Benchee.Scenario{memory_usage_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 2}}}
121
- iex> measurement_data(scenario, :memory)
123
+ iex> scenario = %Benchee.Scenario{
124
+ ...> memory_usage_data: %Benchee.CollectionData{
125
+ ...> statistics: %Benchee.Statistics{sample_size: 2}
126
+ ...> }
127
+ ...> }
128
+ ...>
129
+ ...> measurement_data(scenario, :memory)
122
130
%Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 2}}
123
131
124
- iex> scenario = %Benchee.Scenario{reductions_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 3}}}
125
- iex> measurement_data(scenario, :reductions)
132
+ iex> scenario = %Benchee.Scenario{
133
+ ...> reductions_data: %Benchee.CollectionData{
134
+ ...> statistics: %Benchee.Statistics{sample_size: 3}
135
+ ...> }
136
+ ...> }
137
+ ...>
138
+ ...> measurement_data(scenario, :reductions)
126
139
%Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 3}}
127
140
128
141
iex> measurement_data(%Benchee.Scenario{}, :memory)
 
@@ -152,20 +165,40 @@ defmodule Benchee.Scenario do
152
165
153
166
## Examples
154
167
155
- iex> scenario = %Benchee.Scenario{run_time_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 100}}}
156
- iex> data_processed?(scenario, :run_time)
168
+ iex> scenario = %Benchee.Scenario{
169
+ ...> run_time_data: %Benchee.CollectionData{
170
+ ...> statistics: %Benchee.Statistics{sample_size: 100}
171
+ ...> }
172
+ ...> }
173
+ ...>
174
+ ...> data_processed?(scenario, :run_time)
157
175
true
158
176
159
- iex> scenario = %Benchee.Scenario{memory_usage_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 1}}}
160
- iex> data_processed?(scenario, :memory)
177
+ iex> scenario = %Benchee.Scenario{
178
+ ...> memory_usage_data: %Benchee.CollectionData{
179
+ ...> statistics: %Benchee.Statistics{sample_size: 1}
180
+ ...> }
181
+ ...> }
182
+ ...>
183
+ ...> data_processed?(scenario, :memory)
161
184
true
162
185
163
- iex> scenario = %Benchee.Scenario{reductions_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 1}}}
164
- iex> data_processed?(scenario, :reductions)
186
+ iex> scenario = %Benchee.Scenario{
187
+ ...> reductions_data: %Benchee.CollectionData{
188
+ ...> statistics: %Benchee.Statistics{sample_size: 1}
189
+ ...> }
190
+ ...> }
191
+ ...>
192
+ ...> data_processed?(scenario, :reductions)
165
193
true
166
194
167
- iex> scenario = %Benchee.Scenario{memory_usage_data: %Benchee.CollectionData{statistics: %Benchee.Statistics{sample_size: 0}}}
168
- iex> data_processed?(scenario, :memory)
195
+ iex> scenario = %Benchee.Scenario{
196
+ ...> memory_usage_data: %Benchee.CollectionData{
197
+ ...> statistics: %Benchee.Statistics{sample_size: 0}
198
+ ...> }
199
+ ...> }
200
+ ...>
201
+ ...> data_processed?(scenario, :memory)
169
202
false
170
203
"""
171
204
@spec data_processed?(t, :run_time | :memory) :: boolean
changed lib/benchee/statistics.ex
 
@@ -115,8 +115,9 @@ defmodule Benchee.Statistics do
115
115
...> input: "Input"
116
116
...> }
117
117
...> ]
118
- iex> suite = %Benchee.Suite{scenarios: scenarios}
119
- iex> statistics(suite, Benchee.Test.FakeProgressPrinter)
118
+ ...>
119
+ ...> suite = %Benchee.Suite{scenarios: scenarios}
120
+ ...> statistics(suite, Benchee.Test.FakeProgressPrinter)
120
121
%Benchee.Suite{
121
122
scenarios: [
122
123
%Benchee.Scenario{
 
@@ -126,33 +127,33 @@ defmodule Benchee.Statistics do
126
127
run_time_data: %Benchee.CollectionData{
127
128
samples: [200, 400, 400, 400, 500, 500, 500, 700, 900],
128
129
statistics: %Benchee.Statistics{
129
- average: 500.0,
130
- ips: 2000_000.0,
131
- std_dev: 200.0,
130
+ average: 500.0,
131
+ ips: 2000_000.0,
132
+ std_dev: 200.0,
132
133
std_dev_ratio: 0.4,
133
- std_dev_ips: 800_000.0,
134
- median: 500.0,
135
- percentiles: %{50 => 500.0, 99 => 900.0},
136
- mode: [500, 400],
137
- minimum: 200,
138
- maximum: 900,
139
- sample_size: 9
134
+ std_dev_ips: 800_000.0,
135
+ median: 500.0,
136
+ percentiles: %{50 => 500.0, 99 => 900.0},
137
+ mode: [500, 400],
138
+ minimum: 200,
139
+ maximum: 900,
140
+ sample_size: 9
140
141
}
141
142
},
142
143
memory_usage_data: %Benchee.CollectionData{
143
144
samples: [200, 400, 400, 400, 500, 500, 500, 700, 900],
144
145
statistics: %Benchee.Statistics{
145
- average: 500.0,
146
- ips: nil,
147
- std_dev: 200.0,
146
+ average: 500.0,
147
+ ips: nil,
148
+ std_dev: 200.0,
148
149
std_dev_ratio: 0.4,
149
- std_dev_ips: nil,
150
- median: 500.0,
151
- percentiles: %{50 => 500.0, 99 => 900.0},
152
- mode: [500, 400],
153
- minimum: 200,
154
- maximum: 900,
155
- sample_size: 9
150
+ std_dev_ips: nil,
151
+ median: 500.0,
152
+ percentiles: %{50 => 500.0, 99 => 900.0},
153
+ mode: [500, 400],
154
+ minimum: 200,
155
+ maximum: 900,
156
+ sample_size: 9
156
157
}
157
158
}
158
159
}
changed lib/benchee/system.ex
 
@@ -4,7 +4,7 @@ defmodule Benchee.System do
4
4
5
5
Includes information such as elixir/erlang version, OS, CPU and memory.
6
6
7
- So far supports/should work for Linux, MacOS, FreeBSD and Windows.
7
+ So far supports/should work for Linux, MacOS, FreeBSD, Solaris and Windows.
8
8
"""
9
9
10
10
alias Benchee.Conversion.Memory
 
@@ -36,7 +36,7 @@ defmodule Benchee.System do
36
36
erlang: String.t(),
37
37
jit_enabled?: boolean(),
38
38
num_cores: pos_integer(),
39
- os: :macOS | :Windows | :FreeBSD | :Linux,
39
+ os: :macOS | :Windows | :FreeBSD | :Solaris | :Linux,
40
40
cpu_speed: String.t(),
41
41
available_memory: String.t()
42
42
}
 
@@ -105,6 +105,7 @@ defmodule Benchee.System do
105
105
defp os(:darwin), do: :macOS
106
106
defp os(:nt), do: :Windows
107
107
defp os(:freebsd), do: :FreeBSD
108
+ defp os(:sunos), do: :Solaris
108
109
defp os(_), do: :Linux
109
110
110
111
defp cpu_speed, do: cpu_speed(os())
 
@@ -121,11 +122,16 @@ defmodule Benchee.System do
121
122
parse_cpu_for(:FreeBSD, system_cmd("sysctl", ["-n", "hw.model"]))
122
123
end
123
124
125
+ defp cpu_speed(:Solaris) do
126
+ parse_cpu_for(:Solaris, system_cmd("kstat", ["-p", "cpu_info:0::brand"]))
127
+ end
128
+
124
129
defp cpu_speed(:Linux) do
125
130
parse_cpu_for(:Linux, system_cmd("cat", ["/proc/cpuinfo"]))
126
131
end
127
132
128
133
@linux_cpuinfo_regex ~r/model name.*:([\w \(\)\-\@\.]*)/i
134
+ @solaris_cpubrand_regex ~r/^cpu_info:0:cpu_info0:brand\s+(.*)\s*$/i
129
135
130
136
@doc false
131
137
def parse_cpu_for(_, "N/A"), do: "N/A"
 
@@ -139,6 +145,15 @@ defmodule Benchee.System do
139
145
140
146
def parse_cpu_for(:FreeBSD, raw_output), do: String.trim(raw_output)
141
147
148
+ def parse_cpu_for(:Solaris, raw_output) do
149
+ match_info = Regex.run(@solaris_cpubrand_regex, raw_output, capture: :all_but_first)
150
+
151
+ case match_info do
152
+ [cpu_info] -> cpu_info
153
+ _ -> "Unrecognized processor"
154
+ end
155
+ end
156
+
142
157
def parse_cpu_for(:Linux, raw_output) do
143
158
match_info = Regex.run(@linux_cpuinfo_regex, raw_output, capture: :all_but_first)
144
159
 
@@ -165,6 +180,10 @@ defmodule Benchee.System do
165
180
parse_memory_for(:FreeBSD, system_cmd("sysctl", ["-n", "hw.physmem"]))
166
181
end
167
182
183
+ defp available_memory(:Solaris) do
184
+ parse_memory_for(:Solaris, system_cmd("prtconf", ["-m"]))
185
+ end
186
+
168
187
defp available_memory(:Linux) do
169
188
parse_memory_for(:Linux, system_cmd("cat", ["/proc/meminfo"]))
170
189
end
 
@@ -187,6 +206,12 @@ defmodule Benchee.System do
187
206
Memory.format(memory)
188
207
end
189
208
209
+ defp parse_memory_for(:Solaris, raw_output) do
210
+ {memory_in_megabytes, _} = Integer.parse(raw_output)
211
+ {memory_in_bytes, _} = Memory.convert({memory_in_megabytes, :megabyte}, :byte)
212
+ Memory.format(memory_in_bytes)
213
+ end
214
+
190
215
defp parse_memory_for(:Linux, raw_output) do
191
216
["MemTotal:" <> memory_info] = Regex.run(~r/MemTotal.*kB/, raw_output)
192
217
 
@@ -230,11 +255,13 @@ defmodule Benchee.System do
230
255
231
256
# just made public for easy testing purposes
232
257
@doc false
233
- def all_protocols_consolidated?(lib_dir_fun \\ &:code.lib_dir/2) do
234
- case lib_dir_fun.(:elixir, :ebin) do
258
+ def all_protocols_consolidated?(lib_dir_fun \\ &:code.lib_dir/1) do
259
+ case lib_dir_fun.(:elixir) do
235
260
# do we get a good old erlang charlist?
236
261
path when is_list(path) ->
237
- [path]
262
+ ebin_path = Path.join(path, "ebin")
263
+
264
+ [ebin_path]
238
265
|> Protocol.extract_protocols()
239
266
|> Enum.all?(&Protocol.consolidated?/1)
changed lib/benchee/utility/deep_convert.ex
 
@@ -8,13 +8,13 @@ defmodule Benchee.Utility.DeepConvert do
8
8
9
9
## Examples
10
10
11
- iex> to_map([a: 1, b: 2])
11
+ iex> to_map(a: 1, b: 2)
12
12
%{a: 1, b: 2}
13
13
14
- iex> to_map([a: [b: 2], c: [d: 3, e: 4, e: 5]])
14
+ iex> to_map(a: [b: 2], c: [d: 3, e: 4, e: 5])
15
15
%{a: %{b: 2}, c: %{d: 3, e: 5}}
16
16
17
- iex> to_map([a: [b: 2], c: [1, 2, 3], d: []])
17
+ iex> to_map(a: [b: 2], c: [1, 2, 3], d: [])
18
18
%{a: %{b: 2}, c: [1, 2, 3], d: []}
19
19
20
20
iex> to_map(%{a: %{b: 2}, c: %{d: 3, e: 5}})
changed lib/benchee/utility/file_creation.ex
 
@@ -78,35 +78,47 @@ defmodule Benchee.Utility.FileCreation do
78
78
iex> interleave("bench/abc.csv", "Big Input")
79
79
"bench/abc_big_input.csv"
80
80
81
- iex> interleave("bench/abc.csv",
82
- ...> ["Big Input"])
81
+ iex> interleave(
82
+ ...> "bench/abc.csv",
83
+ ...> ["Big Input"]
84
+ ...> )
83
85
"bench/abc_big_input.csv"
84
86
85
87
iex> interleave("abc.csv", [])
86
88
"abc.csv"
87
89
88
- iex> interleave("bench/abc.csv",
89
- ...> ["Big Input", "Comparison"])
90
+ iex> interleave(
91
+ ...> "bench/abc.csv",
92
+ ...> ["Big Input", "Comparison"]
93
+ ...> )
90
94
"bench/abc_big_input_comparison.csv"
91
95
92
- iex> interleave("bench/A B C.csv",
93
- ...> ["Big Input", "Comparison"])
96
+ iex> interleave(
97
+ ...> "bench/A B C.csv",
98
+ ...> ["Big Input", "Comparison"]
99
+ ...> )
94
100
"bench/A B C_big_input_comparison.csv"
95
101
96
- iex> interleave("bench/abc.csv",
97
- ...> ["Big Input", "Comparison", "great Stuff"])
102
+ iex> interleave(
103
+ ...> "bench/abc.csv",
104
+ ...> ["Big Input", "Comparison", "great Stuff"]
105
+ ...> )
98
106
"bench/abc_big_input_comparison_great_stuff.csv"
99
107
100
108
iex> marker = Benchee.Benchmark.no_input()
101
- iex> interleave("abc.csv", marker)
109
+ ...> interleave("abc.csv", marker)
102
110
"abc.csv"
103
111
iex> interleave("abc.csv", [marker])
104
112
"abc.csv"
105
- iex> interleave("abc.csv",
106
- ...> [marker, "Comparison"])
113
+ iex> interleave(
114
+ ...> "abc.csv",
115
+ ...> [marker, "Comparison"]
116
+ ...> )
107
117
"abc_comparison.csv"
108
- iex> interleave("abc.csv",
109
- ...> ["Something cool", marker, "Comparison"])
118
+ iex> interleave(
119
+ ...> "abc.csv",
120
+ ...> ["Something cool", marker, "Comparison"]
121
+ ...> )
110
122
"abc_something_cool_comparison.csv"
111
123
"""
112
124
@spec interleave(String.t(), String.t() | list(String.t())) :: String.t()
changed mix.exs
 
@@ -2,7 +2,7 @@ defmodule Benchee.Mixfile do
2
2
use Mix.Project
3
3
4
4
@source_url "https://github.com/bencheeorg/benchee"
5
- @version "1.3.0"
5
+ @version "1.3.1"
6
6
7
7
def project do
8
8
[
 
@@ -46,10 +46,11 @@ defmodule Benchee.Mixfile do
46
46
{:deep_merge, "~> 1.0"},
47
47
{:statistex, "~> 1.0"},
48
48
{:ex_guard, "~> 1.3", only: :dev},
49
- {:credo, "~> 1.7.2-rc.0", only: :dev, runtime: false},
49
+ {:credo, "~> 1.7.7-rc.0", only: :dev, runtime: false},
50
50
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
51
51
{:excoveralls, "~> 0.13", only: :test},
52
- {:dialyxir, "~> 1.0", only: :dev, runtime: false}
52
+ {:dialyxir, "~> 1.0", only: :dev, runtime: false},
53
+ {:doctest_formatter, "~> 0.2", only: :dev, runtime: false}
53
54
]
54
55
55
56
# table relies on __STACKTRACE__ which was introduced in 1.7, we still support ~>1.6 though