aboutsummaryrefslogtreecommitdiff
path: root/analysis
diff options
context:
space:
mode:
Diffstat (limited to 'analysis')
-rw-r--r--analysis/vis.livemd55
1 files changed, 42 insertions, 13 deletions
diff --git a/analysis/vis.livemd b/analysis/vis.livemd
index 48b8e59..0aa2711 100644
--- a/analysis/vis.livemd
+++ b/analysis/vis.livemd
@@ -87,6 +87,16 @@ cost_model_points =
|> DF.new()
end)
|> DF.concat_rows()
+```
+
+```elixir
+# Discard points outside one standard deviation, as we do when fitting
+cost_model_points =
+ cost_model_points
+ |> DF.group_by(["impl", "op", "n"])
+ |> DF.mutate(avg: mean(t), dev: standard_deviation(t))
+ |> DF.filter(abs(t - avg) < dev)
+ |> DF.discard(["avg", "dev"])
|> DF.mutate(t: cast(t, {:duration, :nanosecond}))
```
@@ -149,15 +159,17 @@ defmodule CostModel do
|> Enum.map(fn %{"impl" => impl} -> points_for(cost_models, ns, impl, op) end)
|> DF.concat_rows()
|> DF.filter(impl in ^impls)
+ |> DF.sort_by(impl)
|> Tucan.lineplot("n", "t", color_by: "impl", clip: true)
] ++
if(draw_points,
do: [
- Tucan.scatter(
- cost_model_points
- |> DF.filter(op == ^op and impl in ^impls)
- |> DF.group_by(["impl", "n"])
- |> DF.summarise(t: mean(cast(t, :f32))),
+ cost_model_points
+ |> DF.filter(op == ^op and impl in ^impls)
+ |> DF.group_by(["impl", "n"])
+ |> DF.sort_by(impl)
+ |> DF.mutate(t: cast(t, :f32))
+ |> Tucan.scatter(
"n",
"t",
color_by: "impl",
@@ -174,6 +186,7 @@ defmodule CostModel do
|> Tucan.Axes.set_x_title("Size of container (n)")
|> Tucan.set_size(500, 250)
|> Tucan.Legend.set_title(:color, "Implementation")
+ |> Tucan.Scale.set_x_domain(ns.first, ns.last)
case y_domain do
[lo, hi] -> Tucan.Scale.set_y_domain(plot, lo, hi)
@@ -186,6 +199,7 @@ defmodule CostModel do
Enum.map(impl_splits, &plot(cost_models, cost_model_points, &1, op))
|> Tucan.vconcat()
+ |> VegaLite.resolve(:scale, color: :independent)
end
end
```
@@ -198,39 +212,54 @@ graph =
cost_models,
cost_model_points,
[
+ ["Vec", "LinkedList"],
["SortedVec", "SortedVecSet", "SortedVecMap", "VecSet", "VecMap"],
- [
- "Vec",
- "LinkedList"
- ],
["BTreeSet", "BTreeMap", "HashSet", "HashMap"]
],
"insert"
)
- |> VegaLite.resolve(:scale, color: :independent)
VegaLite.Export.save!(graph, "../thesis/assets/insert.json")
graph
```
+<!-- livebook:{"reevaluate_automatically":true} -->
+
+```elixir
+graph =
+ CostModel.plot(
+ cost_models,
+ cost_model_points,
+ ["VecSet", "SortedVecSet", "HashSet", "BTreeSet"],
+ "insert",
+ ns: 1..3000//10,
+ y_domain: [0, 200],
+ draw_points: false
+ )
+
+VegaLite.Export.save!(graph, "../thesis/assets/insert_small_n.json")
+
+graph
+```
+
```elixir
graph =
CostModel.split_plot(
cost_models,
cost_model_points,
[
- ["SortedVec", "SortedVecSet", "SortedVecMap", "VecSet"],
+ ["SortedVec", "SortedVecSet", "SortedVecMap"],
[
"Vec",
"LinkedList",
- "VecMap"
+ "VecMap",
+ "VecSet"
],
["BTreeSet", "BTreeMap", "HashSet", "HashMap"]
],
"contains"
)
- |> VegaLite.resolve(:scale, color: :independent)
VegaLite.Export.save!(graph, "../thesis/assets/contains.json")