Skip to content

Commit

Permalink
fix doctest for a world with non determintistic maps as they should be
Browse files Browse the repository at this point in the history
  • Loading branch information
PragTob committed Nov 9, 2023
1 parent ed6c599 commit 518f849
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
49 changes: 47 additions & 2 deletions lib/benchee/formatters/json.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,53 @@ defmodule Benchee.Formatters.JSON do
...> },
...> ]
...> }
iex> Benchee.Formatters.JSON.format(suite, %{file: "my_file.json"})
"[{\\"name\\":\\"My Job\\",\\"job_name\\":\\"My Job\\",\\"input_name\\":\\"Some Input\\",\\"run_time_data\\":{\\"statistics\\":{\\"absolute_difference\\":null,\\"average\\":500.0,\\"ips\\":2.0e3,\\"maximum\\":900,\\"median\\":450.0,\\"minimum\\":200,\\"mode\\":400,\\"percentiles\\":{\\"99\\":900},\\"relative_less\\":null,\\"relative_more\\":null,\\"sample_size\\":8,\\"std_dev\\":200.0,\\"std_dev_ips\\":800.0,\\"std_dev_ratio\\":0.4},\\"samples\\":[200,400,400,400,500,500,700,900]},\\"memory_usage_data\\":{\\"statistics\\":{\\"absolute_difference\\":null,\\"average\\":500.0,\\"ips\\":null,\\"maximum\\":900,\\"median\\":450.0,\\"minimum\\":200,\\"mode\\":null,\\"percentiles\\":{\\"99\\":900},\\"relative_less\\":null,\\"relative_more\\":null,\\"sample_size\\":8,\\"std_dev\\":200.0,\\"std_dev_ips\\":null,\\"std_dev_ratio\\":0.4},\\"samples\\":[200,400,400,400,500,500,700,900]},\\"tag\\":null}]"
iex> suite |> format(%{file: "my_file.json"}) |> Jason.decode!()
[
%{
"input_name" => "Some Input",
"name" => "My Job",
"job_name" => "My Job",
"tag" => nil,
"memory_usage_data" => %{
"samples" => [200, 400, 400, 400, 500, 500, 700, 900],
"statistics" => %{
"absolute_difference" => nil,
"average" => 500.0,
"ips" => nil,
"maximum" => 900,
"median" => 450.0,
"minimum" => 200,
"mode" => nil,
"percentiles" => %{"99" => 900},
"relative_less" => nil,
"relative_more" => nil,
"sample_size" => 8,
"std_dev" => 200.0,
"std_dev_ips" => nil,
"std_dev_ratio" => 0.4
}
},
"run_time_data" => %{
"samples" => [200, 400, 400, 400, 500, 500, 700, 900],
"statistics" => %{
"absolute_difference" => nil,
"average" => 500.0,
"ips" => 2000.0,
"maximum" => 900,
"median" => 450.0,
"minimum" => 200,
"mode" => 400,
"percentiles" => %{"99" => 900},
"relative_less" => nil,
"relative_more" => nil,
"sample_size" => 8,
"std_dev" => 200.0,
"std_dev_ips" => 800.0,
"std_dev_ratio" => 0.4
}
},
}
]
"""
@spec format(Suite.t(), map) :: String.t()
Expand Down
2 changes: 1 addition & 1 deletion test/benchee/formatters/json_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Benchee.Formatters.JSONTest do
use ExUnit.Case, async: true
doctest Benchee.Formatters.JSON
doctest Benchee.Formatters.JSON, import: true

alias Benchee.{Formatters.JSON, Suite}

Expand Down

0 comments on commit 518f849

Please sign in to comment.