File tree Expand file tree Collapse file tree 2 files changed +62
-12
lines changed
Expand file tree Collapse file tree 2 files changed +62
-12
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,12 @@ defmodule Benchee.Benchmark.RunnerTest do
88 alias Benchee.Test.FakeBenchmarkPrinter
99 alias Benchee.Test.FakeProgressPrinter
1010
11+ # times are in ns, so this is 40ms
12+ @ small_time 40_000_000
13+
1114 @ config % Configuration {
1215 parallel: 1 ,
13- time: 40_000_000 ,
16+ time: @ small_time ,
1417 warmup: 20_000_000 ,
1518 inputs: nil ,
1619 pre_check: false ,
@@ -475,6 +478,28 @@ defmodule Benchee.Benchmark.RunnerTest do
475478 |> Benchmark . collect ( FakeBenchmarkPrinter )
476479 end
477480 end
481+
482+ test "max_sample_size is abided by across all times" do
483+ max_sample_size = 3
484+
485+ % Suite { scenarios: [ scenario ] } =
486+ % Suite {
487+ configuration: % Configuration {
488+ max_sample_size: max_sample_size ,
489+ # each one of those should easily be able to gather the samples in time
490+ time: @ small_time ,
491+ memory_time: @ small_time ,
492+ reduction_time: @ small_time
493+ }
494+ }
495+ |> Benchmark . benchmark ( "some benchmak" , fn -> 2 end )
496+ |> Benchmark . collect ( FakeBenchmarkPrinter )
497+
498+ # if it starts going flakey might need to do <= which is in the spirit of max
499+ assert length ( scenario . run_time_data . samples ) == max_sample_size
500+ assert length ( scenario . memory_usage_data . samples ) == max_sample_size
501+ assert length ( scenario . reductions_data . samples ) == max_sample_size
502+ end
478503 end
479504
480505 # hooks are pretty much their own beast
Original file line number Diff line number Diff line change @@ -214,22 +214,22 @@ defmodule BencheeTest do
214214 refute output =~ ~r/ fast/
215215 end
216216
217+ @ disable_all_output_options [
218+ print: [
219+ fast_warning: false ,
220+ benchmarking: false ,
221+ configuration: false
222+ ] ,
223+ formatters: [ ]
224+ ]
217225 test "integration disabling all output configs and formatters we're left with an empty output" do
218226 output =
219227 capture_io ( fn ->
220228 Benchee . run (
221229 % { "Blitz" => fn -> 0 end } ,
222- Keyword . merge (
223- @ test_configuration ,
224- time: 0.001 ,
225- warmup: 0 ,
226- print: [
227- fast_warning: false ,
228- benchmarking: false ,
229- configuration: false
230- ] ,
231- formatters: [ ]
232- )
230+ @ test_configuration
231+ |> Keyword . merge ( time: 0.001 , warmup: 0 )
232+ |> Keyword . merge ( @ disable_all_output_options )
233233 )
234234 end )
235235
@@ -492,6 +492,31 @@ defmodule BencheeTest do
492492 assert length ( occurrences ) == 2
493493 end
494494
495+ test "max_sample_size & multiple inputs with very fast functions" do
496+ max_sample_size = 3
497+
498+ configuration =
499+ @ test_configuration
500+ |> Keyword . merge ( @ disable_all_output_options )
501+ |> Keyword . merge (
502+ max_sample_size: max_sample_size ,
503+ inputs: % { "number_one" => 1 , :symbole_one => :one }
504+ )
505+
506+ suite =
507+ Benchee . run (
508+ % {
509+ "identity" => fn i -> i end
510+ } ,
511+ configuration
512+ )
513+
514+ Enum . each ( suite . scenarios , fn scenario ->
515+ # if this becomes flakey, change to <=
516+ assert scenario . run_time_data . statistics . sample_size == max_sample_size
517+ end )
518+ end
519+
495520 test ".run returns the suite intact" do
496521 capture_io ( fn ->
497522 suite =
You can’t perform that action at this time.
0 commit comments