Skip to content

Commit 2cf5dc5

Browse files
committed
Actually map over new statistics and explain why we do the mapping
1 parent d57cbaa commit 2cf5dc5

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

lib/benchee/statistics.ex

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ defmodule Benchee.Statistics do
2525
:relative_more,
2626
:relative_less,
2727
:absolute_difference,
28+
:outliers,
29+
:lower_outlier_bound,
30+
:upper_outlier_bound,
2831
sample_size: 0
2932
]
3033

@@ -85,6 +88,9 @@ defmodule Benchee.Statistics do
8588
relative_more: float | nil | :infinity,
8689
relative_less: float | nil | :infinity,
8790
absolute_difference: float | nil,
91+
outliers: [number],
92+
lower_outlier_bound: number,
93+
upper_outlier_bound: number,
8894
sample_size: integer
8995
}
9096

@@ -115,7 +121,7 @@ defmodule Benchee.Statistics do
115121
...> input: "Input"
116122
...> }
117123
...> ]
118-
...>
124+
...>
119125
...> suite = %Benchee.Suite{scenarios: scenarios}
120126
...> statistics(suite, Benchee.Test.FakeProgressPrinter)
121127
%Benchee.Suite{
@@ -137,7 +143,10 @@ defmodule Benchee.Statistics do
137143
mode: [500, 400],
138144
minimum: 200,
139145
maximum: 900,
140-
sample_size: 9
146+
sample_size: 9,
147+
outliers: [],
148+
lower_outlier_bound: 100.0,
149+
upper_outlier_bound: 900.0
141150
}
142151
},
143152
memory_usage_data: %Benchee.CollectionData{
@@ -153,7 +162,10 @@ defmodule Benchee.Statistics do
153162
mode: [500, 400],
154163
minimum: 200,
155164
maximum: 900,
156-
sample_size: 9
165+
sample_size: 9,
166+
outliers: [],
167+
lower_outlier_bound: 100.0,
168+
upper_outlier_bound: 900.0
157169
}
158170
}
159171
}
@@ -247,6 +259,14 @@ defmodule Benchee.Statistics do
247259
|> convert_from_statistex
248260
end
249261

262+
# It might seem silly to maintain and map statistex to our own struct,
263+
# but this gives benchee more control and makes it safer to upgrade and change.
264+
# Also, we don't expose changes in statistex versions automatically to plugins.
265+
#
266+
# As an example right now it's being discussed in statistex to add an `m2` statistic that holds
267+
# no value for benchee (as it's ony used to calculate variance).
268+
#
269+
# We also manually add `ips` related stats (see `add_ips/1`) so differences are sufficient.
250270
defp convert_from_statistex(statistex_statistics) do
251271
%__MODULE__{
252272
average: statistex_statistics.average,
@@ -257,7 +277,10 @@ defmodule Benchee.Statistics do
257277
mode: statistex_statistics.mode,
258278
minimum: statistex_statistics.minimum,
259279
maximum: statistex_statistics.maximum,
260-
sample_size: statistex_statistics.sample_size
280+
sample_size: statistex_statistics.sample_size,
281+
outliers: statistex_statistics.outliers,
282+
lower_outlier_bound: statistex_statistics.lower_outlier_bound,
283+
upper_outlier_bound: statistex_statistics.upper_outlier_bound
261284
}
262285
end
263286

test/fixtures/escript/mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
%{
22
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
3-
"statistex": {:hex, :statistex, "1.0.0", "f3dc93f3c0c6c92e5f291704cf62b99b553253d7969e9a5fa713e5481cd858a5", [:mix], [], "hexpm", "ff9d8bee7035028ab4742ff52fc80a2aa35cece833cf5319009b52f1b5a86c27"},
3+
"statistex": {:hex, :statistex, "1.1.0", "7fec1eb2f580a0d2c1a05ed27396a084ab064a40cfc84246dbfb0c72a5c761e5", [:mix], [], "hexpm", "f5950ea26ad43246ba2cce54324ac394a4e7408fdcf98b8e230f503a0cba9cf5"},
44
}

0 commit comments

Comments
 (0)