From a8761625ef3dd4582b4322263ca0b207149ad8a5 Mon Sep 17 00:00:00 2001 From: Mitchell Hanberg Date: Thu, 28 Nov 2019 19:19:06 -0500 Subject: [PATCH] Add benchmarking --- README.md | 12 ++++++++---- ...dvent_of_code_2018.ex => advent_of_code_2019.ex} | 0 .../day_01.ex | 0 .../day_02.ex | 0 .../day_03.ex | 0 .../day_04.ex | 0 .../day_05.ex | 0 .../day_06.ex | 0 .../day_07.ex | 0 .../day_08.ex | 0 .../day_09.ex | 0 .../day_10.ex | 0 .../day_11.ex | 0 .../day_12.ex | 0 .../day_13.ex | 0 .../day_14.ex | 0 .../day_15.ex | 0 .../day_16.ex | 0 .../day_17.ex | 0 .../day_18.ex | 0 .../day_19.ex | 0 .../day_20.ex | 0 .../day_21.ex | 0 .../day_22.ex | 0 .../day_23.ex | 0 .../day_24.ex | 0 .../day_25.ex | 0 lib/mix/tasks/d01.p1.ex | 13 ++++++++----- lib/mix/tasks/d01.p2.ex | 13 ++++++++----- lib/mix/tasks/d02.p1.ex | 13 ++++++++----- lib/mix/tasks/d02.p2.ex | 13 ++++++++----- lib/mix/tasks/d03.p1.ex | 13 ++++++++----- lib/mix/tasks/d03.p2.ex | 13 ++++++++----- lib/mix/tasks/d04.p1.ex | 13 ++++++++----- lib/mix/tasks/d04.p2.ex | 13 ++++++++----- lib/mix/tasks/d05.p1.ex | 13 ++++++++----- lib/mix/tasks/d05.p2.ex | 13 ++++++++----- lib/mix/tasks/d06.p1.ex | 13 ++++++++----- lib/mix/tasks/d06.p2.ex | 13 ++++++++----- lib/mix/tasks/d07.p1.ex | 13 ++++++++----- lib/mix/tasks/d07.p2.ex | 13 ++++++++----- lib/mix/tasks/d08.p1.ex | 13 ++++++++----- lib/mix/tasks/d08.p2.ex | 13 ++++++++----- lib/mix/tasks/d09.p1.ex | 13 ++++++++----- lib/mix/tasks/d09.p2.ex | 13 ++++++++----- lib/mix/tasks/d10.p1.ex | 13 ++++++++----- lib/mix/tasks/d10.p2.ex | 13 ++++++++----- lib/mix/tasks/d11.p1.ex | 13 ++++++++----- lib/mix/tasks/d11.p2.ex | 13 ++++++++----- lib/mix/tasks/d12.p1.ex | 13 ++++++++----- lib/mix/tasks/d12.p2.ex | 13 ++++++++----- lib/mix/tasks/d13.p1.ex | 13 ++++++++----- lib/mix/tasks/d13.p2.ex | 13 ++++++++----- lib/mix/tasks/d14.p1.ex | 13 ++++++++----- lib/mix/tasks/d14.p2.ex | 13 ++++++++----- lib/mix/tasks/d15.p1.ex | 13 ++++++++----- lib/mix/tasks/d15.p2.ex | 13 ++++++++----- lib/mix/tasks/d16.p1.ex | 13 ++++++++----- lib/mix/tasks/d16.p2.ex | 13 ++++++++----- lib/mix/tasks/d17.p1.ex | 13 ++++++++----- lib/mix/tasks/d17.p2.ex | 13 ++++++++----- lib/mix/tasks/d18.p1.ex | 13 ++++++++----- lib/mix/tasks/d18.p2.ex | 13 ++++++++----- lib/mix/tasks/d19.p1.ex | 13 ++++++++----- lib/mix/tasks/d19.p2.ex | 13 ++++++++----- lib/mix/tasks/d20.p1.ex | 13 ++++++++----- lib/mix/tasks/d20.p2.ex | 13 ++++++++----- lib/mix/tasks/d21.p1.ex | 13 ++++++++----- lib/mix/tasks/d21.p2.ex | 13 ++++++++----- lib/mix/tasks/d22.p1.ex | 13 ++++++++----- lib/mix/tasks/d22.p2.ex | 13 ++++++++----- lib/mix/tasks/d23.p1.ex | 13 ++++++++----- lib/mix/tasks/d23.p2.ex | 13 ++++++++----- lib/mix/tasks/d24.p1.ex | 13 ++++++++----- lib/mix/tasks/d24.p2.ex | 13 ++++++++----- lib/mix/tasks/d25.p1.ex | 13 ++++++++----- lib/mix/tasks/d25.p2.ex | 13 ++++++++----- mix.exs | 3 +-- test/advent_of_code_2018/day_01_test.exs | 4 ++-- test/advent_of_code_2018/day_02_test.exs | 4 ++-- test/advent_of_code_2018/day_03_test.exs | 4 ++-- test/advent_of_code_2018/day_04_test.exs | 4 ++-- test/advent_of_code_2018/day_05_test.exs | 4 ++-- test/advent_of_code_2018/day_06_test.exs | 4 ++-- test/advent_of_code_2018/day_07_test.exs | 4 ++-- test/advent_of_code_2018/day_08_test.exs | 4 ++-- test/advent_of_code_2018/day_09_test.exs | 4 ++-- test/advent_of_code_2018/day_10_test.exs | 4 ++-- test/advent_of_code_2018/day_11_test.exs | 4 ++-- test/advent_of_code_2018/day_12_test.exs | 4 ++-- test/advent_of_code_2018/day_13_test.exs | 4 ++-- test/advent_of_code_2018/day_14_test.exs | 4 ++-- test/advent_of_code_2018/day_15_test.exs | 4 ++-- test/advent_of_code_2018/day_16_test.exs | 4 ++-- test/advent_of_code_2018/day_17_test.exs | 4 ++-- test/advent_of_code_2018/day_18_test.exs | 4 ++-- test/advent_of_code_2018/day_19_test.exs | 4 ++-- test/advent_of_code_2018/day_20_test.exs | 4 ++-- test/advent_of_code_2018/day_21_test.exs | 4 ++-- test/advent_of_code_2018/day_22_test.exs | 4 ++-- test/advent_of_code_2018/day_23_test.exs | 4 ++-- test/advent_of_code_2018/day_24_test.exs | 4 ++-- test/advent_of_code_2018/day_25_test.exs | 4 ++-- 103 files changed, 459 insertions(+), 306 deletions(-) rename lib/{advent_of_code_2018.ex => advent_of_code_2019.ex} (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_01.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_02.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_03.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_04.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_05.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_06.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_07.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_08.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_09.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_10.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_11.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_12.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_13.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_14.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_15.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_16.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_17.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_18.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_19.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_20.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_21.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_22.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_23.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_24.ex (100%) rename lib/{advent_of_code_2018 => advent_of_code_2019}/day_25.ex (100%) diff --git a/README.md b/README.md index b0a9832..93d1ee2 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ There are 25 modules, 25 tests, and 50 mix tasks. 1. Fill in the tests with the example solutions. 1. Write your implementation. 1. Fill in the final problem inputs into the mix task and run `mix d01.p1`! + - Benchmark your solution by passing the `-b` flag, `mix d01.p1 -b` ```elixir defmodule AdventOfCode2019.Day01 do @@ -51,12 +52,15 @@ defmodule Mix.Tasks.D01.P1 do import AdventOfCode2019.Day01 @shortdoc "Day 01 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end end ``` diff --git a/lib/advent_of_code_2018.ex b/lib/advent_of_code_2019.ex similarity index 100% rename from lib/advent_of_code_2018.ex rename to lib/advent_of_code_2019.ex diff --git a/lib/advent_of_code_2018/day_01.ex b/lib/advent_of_code_2019/day_01.ex similarity index 100% rename from lib/advent_of_code_2018/day_01.ex rename to lib/advent_of_code_2019/day_01.ex diff --git a/lib/advent_of_code_2018/day_02.ex b/lib/advent_of_code_2019/day_02.ex similarity index 100% rename from lib/advent_of_code_2018/day_02.ex rename to lib/advent_of_code_2019/day_02.ex diff --git a/lib/advent_of_code_2018/day_03.ex b/lib/advent_of_code_2019/day_03.ex similarity index 100% rename from lib/advent_of_code_2018/day_03.ex rename to lib/advent_of_code_2019/day_03.ex diff --git a/lib/advent_of_code_2018/day_04.ex b/lib/advent_of_code_2019/day_04.ex similarity index 100% rename from lib/advent_of_code_2018/day_04.ex rename to lib/advent_of_code_2019/day_04.ex diff --git a/lib/advent_of_code_2018/day_05.ex b/lib/advent_of_code_2019/day_05.ex similarity index 100% rename from lib/advent_of_code_2018/day_05.ex rename to lib/advent_of_code_2019/day_05.ex diff --git a/lib/advent_of_code_2018/day_06.ex b/lib/advent_of_code_2019/day_06.ex similarity index 100% rename from lib/advent_of_code_2018/day_06.ex rename to lib/advent_of_code_2019/day_06.ex diff --git a/lib/advent_of_code_2018/day_07.ex b/lib/advent_of_code_2019/day_07.ex similarity index 100% rename from lib/advent_of_code_2018/day_07.ex rename to lib/advent_of_code_2019/day_07.ex diff --git a/lib/advent_of_code_2018/day_08.ex b/lib/advent_of_code_2019/day_08.ex similarity index 100% rename from lib/advent_of_code_2018/day_08.ex rename to lib/advent_of_code_2019/day_08.ex diff --git a/lib/advent_of_code_2018/day_09.ex b/lib/advent_of_code_2019/day_09.ex similarity index 100% rename from lib/advent_of_code_2018/day_09.ex rename to lib/advent_of_code_2019/day_09.ex diff --git a/lib/advent_of_code_2018/day_10.ex b/lib/advent_of_code_2019/day_10.ex similarity index 100% rename from lib/advent_of_code_2018/day_10.ex rename to lib/advent_of_code_2019/day_10.ex diff --git a/lib/advent_of_code_2018/day_11.ex b/lib/advent_of_code_2019/day_11.ex similarity index 100% rename from lib/advent_of_code_2018/day_11.ex rename to lib/advent_of_code_2019/day_11.ex diff --git a/lib/advent_of_code_2018/day_12.ex b/lib/advent_of_code_2019/day_12.ex similarity index 100% rename from lib/advent_of_code_2018/day_12.ex rename to lib/advent_of_code_2019/day_12.ex diff --git a/lib/advent_of_code_2018/day_13.ex b/lib/advent_of_code_2019/day_13.ex similarity index 100% rename from lib/advent_of_code_2018/day_13.ex rename to lib/advent_of_code_2019/day_13.ex diff --git a/lib/advent_of_code_2018/day_14.ex b/lib/advent_of_code_2019/day_14.ex similarity index 100% rename from lib/advent_of_code_2018/day_14.ex rename to lib/advent_of_code_2019/day_14.ex diff --git a/lib/advent_of_code_2018/day_15.ex b/lib/advent_of_code_2019/day_15.ex similarity index 100% rename from lib/advent_of_code_2018/day_15.ex rename to lib/advent_of_code_2019/day_15.ex diff --git a/lib/advent_of_code_2018/day_16.ex b/lib/advent_of_code_2019/day_16.ex similarity index 100% rename from lib/advent_of_code_2018/day_16.ex rename to lib/advent_of_code_2019/day_16.ex diff --git a/lib/advent_of_code_2018/day_17.ex b/lib/advent_of_code_2019/day_17.ex similarity index 100% rename from lib/advent_of_code_2018/day_17.ex rename to lib/advent_of_code_2019/day_17.ex diff --git a/lib/advent_of_code_2018/day_18.ex b/lib/advent_of_code_2019/day_18.ex similarity index 100% rename from lib/advent_of_code_2018/day_18.ex rename to lib/advent_of_code_2019/day_18.ex diff --git a/lib/advent_of_code_2018/day_19.ex b/lib/advent_of_code_2019/day_19.ex similarity index 100% rename from lib/advent_of_code_2018/day_19.ex rename to lib/advent_of_code_2019/day_19.ex diff --git a/lib/advent_of_code_2018/day_20.ex b/lib/advent_of_code_2019/day_20.ex similarity index 100% rename from lib/advent_of_code_2018/day_20.ex rename to lib/advent_of_code_2019/day_20.ex diff --git a/lib/advent_of_code_2018/day_21.ex b/lib/advent_of_code_2019/day_21.ex similarity index 100% rename from lib/advent_of_code_2018/day_21.ex rename to lib/advent_of_code_2019/day_21.ex diff --git a/lib/advent_of_code_2018/day_22.ex b/lib/advent_of_code_2019/day_22.ex similarity index 100% rename from lib/advent_of_code_2018/day_22.ex rename to lib/advent_of_code_2019/day_22.ex diff --git a/lib/advent_of_code_2018/day_23.ex b/lib/advent_of_code_2019/day_23.ex similarity index 100% rename from lib/advent_of_code_2018/day_23.ex rename to lib/advent_of_code_2019/day_23.ex diff --git a/lib/advent_of_code_2018/day_24.ex b/lib/advent_of_code_2019/day_24.ex similarity index 100% rename from lib/advent_of_code_2018/day_24.ex rename to lib/advent_of_code_2019/day_24.ex diff --git a/lib/advent_of_code_2018/day_25.ex b/lib/advent_of_code_2019/day_25.ex similarity index 100% rename from lib/advent_of_code_2018/day_25.ex rename to lib/advent_of_code_2019/day_25.ex diff --git a/lib/mix/tasks/d01.p1.ex b/lib/mix/tasks/d01.p1.ex index 65ff22e..379df3e 100644 --- a/lib/mix/tasks/d01.p1.ex +++ b/lib/mix/tasks/d01.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D01.P1 do import AdventOfCode2019.Day01 @shortdoc "Day 01 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d01.p2.ex b/lib/mix/tasks/d01.p2.ex index a319cbc..ed756c0 100644 --- a/lib/mix/tasks/d01.p2.ex +++ b/lib/mix/tasks/d01.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D01.P2 do import AdventOfCode2019.Day01 @shortdoc "Day 01 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d02.p1.ex b/lib/mix/tasks/d02.p1.ex index 6e84c20..2f8b7f3 100644 --- a/lib/mix/tasks/d02.p1.ex +++ b/lib/mix/tasks/d02.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D02.P1 do import AdventOfCode2019.Day02 @shortdoc "Day 02 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d02.p2.ex b/lib/mix/tasks/d02.p2.ex index ddef928..1a92b88 100644 --- a/lib/mix/tasks/d02.p2.ex +++ b/lib/mix/tasks/d02.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D02.P2 do import AdventOfCode2019.Day02 @shortdoc "Day 02 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d03.p1.ex b/lib/mix/tasks/d03.p1.ex index 92d4a3a..dbd1882 100644 --- a/lib/mix/tasks/d03.p1.ex +++ b/lib/mix/tasks/d03.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D03.P1 do import AdventOfCode2019.Day03 @shortdoc "Day 03 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d03.p2.ex b/lib/mix/tasks/d03.p2.ex index 2b3ff1e..f3d920d 100644 --- a/lib/mix/tasks/d03.p2.ex +++ b/lib/mix/tasks/d03.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D03.P2 do import AdventOfCode2019.Day03 @shortdoc "Day 03 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d04.p1.ex b/lib/mix/tasks/d04.p1.ex index d6a0c62..e1a1d76 100644 --- a/lib/mix/tasks/d04.p1.ex +++ b/lib/mix/tasks/d04.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D04.P1 do import AdventOfCode2019.Day04 @shortdoc "Day 04 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d04.p2.ex b/lib/mix/tasks/d04.p2.ex index 86ddb04..ad611b5 100644 --- a/lib/mix/tasks/d04.p2.ex +++ b/lib/mix/tasks/d04.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D04.P2 do import AdventOfCode2019.Day04 @shortdoc "Day 04 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d05.p1.ex b/lib/mix/tasks/d05.p1.ex index 5e44ae6..1925093 100644 --- a/lib/mix/tasks/d05.p1.ex +++ b/lib/mix/tasks/d05.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D05.P1 do import AdventOfCode2019.Day05 @shortdoc "Day 05 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d05.p2.ex b/lib/mix/tasks/d05.p2.ex index ed8360a..fce9e4f 100644 --- a/lib/mix/tasks/d05.p2.ex +++ b/lib/mix/tasks/d05.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D05.P2 do import AdventOfCode2019.Day05 @shortdoc "Day 05 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d06.p1.ex b/lib/mix/tasks/d06.p1.ex index 7ae7a2c..41da306 100644 --- a/lib/mix/tasks/d06.p1.ex +++ b/lib/mix/tasks/d06.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D06.P1 do import AdventOfCode2019.Day06 @shortdoc "Day 06 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d06.p2.ex b/lib/mix/tasks/d06.p2.ex index c3bcf07..6e0ea18 100644 --- a/lib/mix/tasks/d06.p2.ex +++ b/lib/mix/tasks/d06.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D06.P2 do import AdventOfCode2019.Day06 @shortdoc "Day 06 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d07.p1.ex b/lib/mix/tasks/d07.p1.ex index 42e33c2..6388a37 100644 --- a/lib/mix/tasks/d07.p1.ex +++ b/lib/mix/tasks/d07.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D07.P1 do import AdventOfCode2019.Day07 @shortdoc "Day 07 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d07.p2.ex b/lib/mix/tasks/d07.p2.ex index 1ff3f7a..1985e5a 100644 --- a/lib/mix/tasks/d07.p2.ex +++ b/lib/mix/tasks/d07.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D07.P2 do import AdventOfCode2019.Day07 @shortdoc "Day 07 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d08.p1.ex b/lib/mix/tasks/d08.p1.ex index 251d3ee..dc16475 100644 --- a/lib/mix/tasks/d08.p1.ex +++ b/lib/mix/tasks/d08.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D08.P1 do import AdventOfCode2019.Day08 @shortdoc "Day 08 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d08.p2.ex b/lib/mix/tasks/d08.p2.ex index d4b11d7..8b6ffd9 100644 --- a/lib/mix/tasks/d08.p2.ex +++ b/lib/mix/tasks/d08.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D08.P2 do import AdventOfCode2019.Day08 @shortdoc "Day 08 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d09.p1.ex b/lib/mix/tasks/d09.p1.ex index 473ec5b..117f228 100644 --- a/lib/mix/tasks/d09.p1.ex +++ b/lib/mix/tasks/d09.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D09.P1 do import AdventOfCode2019.Day09 @shortdoc "Day 09 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d09.p2.ex b/lib/mix/tasks/d09.p2.ex index 75f0732..3c9e899 100644 --- a/lib/mix/tasks/d09.p2.ex +++ b/lib/mix/tasks/d09.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D09.P2 do import AdventOfCode2019.Day09 @shortdoc "Day 09 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d10.p1.ex b/lib/mix/tasks/d10.p1.ex index 61a2d87..868d3ac 100644 --- a/lib/mix/tasks/d10.p1.ex +++ b/lib/mix/tasks/d10.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D10.P1 do import AdventOfCode2019.Day10 @shortdoc "Day 10 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d10.p2.ex b/lib/mix/tasks/d10.p2.ex index 37a0f3d..37323b4 100644 --- a/lib/mix/tasks/d10.p2.ex +++ b/lib/mix/tasks/d10.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D10.P2 do import AdventOfCode2019.Day10 @shortdoc "Day 10 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d11.p1.ex b/lib/mix/tasks/d11.p1.ex index ebad4b2..e010e2c 100644 --- a/lib/mix/tasks/d11.p1.ex +++ b/lib/mix/tasks/d11.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D11.P1 do import AdventOfCode2019.Day11 @shortdoc "Day 11 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d11.p2.ex b/lib/mix/tasks/d11.p2.ex index e52e6df..ccfdb30 100644 --- a/lib/mix/tasks/d11.p2.ex +++ b/lib/mix/tasks/d11.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D11.P2 do import AdventOfCode2019.Day11 @shortdoc "Day 11 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d12.p1.ex b/lib/mix/tasks/d12.p1.ex index bc45e14..57ca601 100644 --- a/lib/mix/tasks/d12.p1.ex +++ b/lib/mix/tasks/d12.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D12.P1 do import AdventOfCode2019.Day12 @shortdoc "Day 12 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d12.p2.ex b/lib/mix/tasks/d12.p2.ex index 79b7d72..b22f51f 100644 --- a/lib/mix/tasks/d12.p2.ex +++ b/lib/mix/tasks/d12.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D12.P2 do import AdventOfCode2019.Day12 @shortdoc "Day 12 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d13.p1.ex b/lib/mix/tasks/d13.p1.ex index 5692f08..bd57b01 100644 --- a/lib/mix/tasks/d13.p1.ex +++ b/lib/mix/tasks/d13.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D13.P1 do import AdventOfCode2019.Day13 @shortdoc "Day 13 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d13.p2.ex b/lib/mix/tasks/d13.p2.ex index 8c21daa..847b571 100644 --- a/lib/mix/tasks/d13.p2.ex +++ b/lib/mix/tasks/d13.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D13.P2 do import AdventOfCode2019.Day13 @shortdoc "Day 13 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d14.p1.ex b/lib/mix/tasks/d14.p1.ex index d14677c..aeb57da 100644 --- a/lib/mix/tasks/d14.p1.ex +++ b/lib/mix/tasks/d14.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D14.P1 do import AdventOfCode2019.Day14 @shortdoc "Day 14 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d14.p2.ex b/lib/mix/tasks/d14.p2.ex index c064393..fb19ab3 100644 --- a/lib/mix/tasks/d14.p2.ex +++ b/lib/mix/tasks/d14.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D14.P2 do import AdventOfCode2019.Day14 @shortdoc "Day 14 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d15.p1.ex b/lib/mix/tasks/d15.p1.ex index afb7dd2..2909d2b 100644 --- a/lib/mix/tasks/d15.p1.ex +++ b/lib/mix/tasks/d15.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D15.P1 do import AdventOfCode2019.Day15 @shortdoc "Day 15 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d15.p2.ex b/lib/mix/tasks/d15.p2.ex index 5e2a149..cd31865 100644 --- a/lib/mix/tasks/d15.p2.ex +++ b/lib/mix/tasks/d15.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D15.P2 do import AdventOfCode2019.Day15 @shortdoc "Day 15 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d16.p1.ex b/lib/mix/tasks/d16.p1.ex index d39c65f..bacbeef 100644 --- a/lib/mix/tasks/d16.p1.ex +++ b/lib/mix/tasks/d16.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D16.P1 do import AdventOfCode2019.Day16 @shortdoc "Day 16 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d16.p2.ex b/lib/mix/tasks/d16.p2.ex index 8039cd2..2b523ae 100644 --- a/lib/mix/tasks/d16.p2.ex +++ b/lib/mix/tasks/d16.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D16.P2 do import AdventOfCode2019.Day16 @shortdoc "Day 16 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d17.p1.ex b/lib/mix/tasks/d17.p1.ex index e0ed0b2..95aea1c 100644 --- a/lib/mix/tasks/d17.p1.ex +++ b/lib/mix/tasks/d17.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D17.P1 do import AdventOfCode2019.Day17 @shortdoc "Day 17 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d17.p2.ex b/lib/mix/tasks/d17.p2.ex index e87c453..4b4d6ef 100644 --- a/lib/mix/tasks/d17.p2.ex +++ b/lib/mix/tasks/d17.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D17.P2 do import AdventOfCode2019.Day17 @shortdoc "Day 17 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d18.p1.ex b/lib/mix/tasks/d18.p1.ex index 93c2486..f90135c 100644 --- a/lib/mix/tasks/d18.p1.ex +++ b/lib/mix/tasks/d18.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D18.P1 do import AdventOfCode2019.Day18 @shortdoc "Day 18 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d18.p2.ex b/lib/mix/tasks/d18.p2.ex index 743dcbb..bb96027 100644 --- a/lib/mix/tasks/d18.p2.ex +++ b/lib/mix/tasks/d18.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D18.P2 do import AdventOfCode2019.Day18 @shortdoc "Day 18 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d19.p1.ex b/lib/mix/tasks/d19.p1.ex index a92aafd..38a7385 100644 --- a/lib/mix/tasks/d19.p1.ex +++ b/lib/mix/tasks/d19.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D19.P1 do import AdventOfCode2019.Day19 @shortdoc "Day 19 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d19.p2.ex b/lib/mix/tasks/d19.p2.ex index d324a30..e03b9fa 100644 --- a/lib/mix/tasks/d19.p2.ex +++ b/lib/mix/tasks/d19.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D19.P2 do import AdventOfCode2019.Day19 @shortdoc "Day 19 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d20.p1.ex b/lib/mix/tasks/d20.p1.ex index f28282f..8a21666 100644 --- a/lib/mix/tasks/d20.p1.ex +++ b/lib/mix/tasks/d20.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D20.P1 do import AdventOfCode2019.Day20 @shortdoc "Day 20 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d20.p2.ex b/lib/mix/tasks/d20.p2.ex index f3fd6ae..0b6b831 100644 --- a/lib/mix/tasks/d20.p2.ex +++ b/lib/mix/tasks/d20.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D20.P2 do import AdventOfCode2019.Day20 @shortdoc "Day 20 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d21.p1.ex b/lib/mix/tasks/d21.p1.ex index 917458e..395df1d 100644 --- a/lib/mix/tasks/d21.p1.ex +++ b/lib/mix/tasks/d21.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D21.P1 do import AdventOfCode2019.Day21 @shortdoc "Day 21 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d21.p2.ex b/lib/mix/tasks/d21.p2.ex index 54a306d..c7d6bec 100644 --- a/lib/mix/tasks/d21.p2.ex +++ b/lib/mix/tasks/d21.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D21.P2 do import AdventOfCode2019.Day21 @shortdoc "Day 21 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d22.p1.ex b/lib/mix/tasks/d22.p1.ex index a7645b6..1aba2b5 100644 --- a/lib/mix/tasks/d22.p1.ex +++ b/lib/mix/tasks/d22.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D22.P1 do import AdventOfCode2019.Day22 @shortdoc "Day 22 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d22.p2.ex b/lib/mix/tasks/d22.p2.ex index cdfb164..9542e89 100644 --- a/lib/mix/tasks/d22.p2.ex +++ b/lib/mix/tasks/d22.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D22.P2 do import AdventOfCode2019.Day22 @shortdoc "Day 22 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d23.p1.ex b/lib/mix/tasks/d23.p1.ex index 3f03023..011dabc 100644 --- a/lib/mix/tasks/d23.p1.ex +++ b/lib/mix/tasks/d23.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D23.P1 do import AdventOfCode2019.Day23 @shortdoc "Day 23 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d23.p2.ex b/lib/mix/tasks/d23.p2.ex index 290a711..4c69eaa 100644 --- a/lib/mix/tasks/d23.p2.ex +++ b/lib/mix/tasks/d23.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D23.P2 do import AdventOfCode2019.Day23 @shortdoc "Day 23 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d24.p1.ex b/lib/mix/tasks/d24.p1.ex index 3fe5a9c..1d48fca 100644 --- a/lib/mix/tasks/d24.p1.ex +++ b/lib/mix/tasks/d24.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D24.P1 do import AdventOfCode2019.Day24 @shortdoc "Day 24 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d24.p2.ex b/lib/mix/tasks/d24.p2.ex index 0838eb9..a23dfc3 100644 --- a/lib/mix/tasks/d24.p2.ex +++ b/lib/mix/tasks/d24.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D24.P2 do import AdventOfCode2019.Day24 @shortdoc "Day 24 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/lib/mix/tasks/d25.p1.ex b/lib/mix/tasks/d25.p1.ex index 3d845fd..b7e589c 100644 --- a/lib/mix/tasks/d25.p1.ex +++ b/lib/mix/tasks/d25.p1.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D25.P1 do import AdventOfCode2019.Day25 @shortdoc "Day 25 Part 1" - def run(_) do + def run(args) do input = nil - input - |> part1() - |> IO.inspect(label: "Part 1 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_1: fn -> input |> part1() end}), + else: + input + |> part1() + |> IO.inspect(label: "Part 1 Results") end -end +end diff --git a/lib/mix/tasks/d25.p2.ex b/lib/mix/tasks/d25.p2.ex index e330410..875b066 100644 --- a/lib/mix/tasks/d25.p2.ex +++ b/lib/mix/tasks/d25.p2.ex @@ -4,11 +4,14 @@ defmodule Mix.Tasks.D25.P2 do import AdventOfCode2019.Day25 @shortdoc "Day 25 Part 2" - def run(_) do + def run(args) do input = nil - input - |> part2() - |> IO.inspect(label: "Part 2 Results") + if Enum.member?(args, "-b"), + do: Benchee.run(%{part_2: fn -> input |> part2() end}), + else: + input + |> part2() + |> IO.inspect(label: "Part 2 Results") end -end +end diff --git a/mix.exs b/mix.exs index 4dbb179..7cb9dd5 100644 --- a/mix.exs +++ b/mix.exs @@ -21,8 +21,7 @@ defmodule AdventOfCode2019.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - # {:dep_from_hexpm, "~> 0.3.0"}, - # {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"}, + {:benchee, "~> 1.0"} ] end end diff --git a/test/advent_of_code_2018/day_01_test.exs b/test/advent_of_code_2018/day_01_test.exs index 37353e9..daebf8e 100644 --- a/test/advent_of_code_2018/day_01_test.exs +++ b/test/advent_of_code_2018/day_01_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day01Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day01Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_02_test.exs b/test/advent_of_code_2018/day_02_test.exs index 95d0537..8991021 100644 --- a/test/advent_of_code_2018/day_02_test.exs +++ b/test/advent_of_code_2018/day_02_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day02Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day02Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_03_test.exs b/test/advent_of_code_2018/day_03_test.exs index 028753d..ac91dc3 100644 --- a/test/advent_of_code_2018/day_03_test.exs +++ b/test/advent_of_code_2018/day_03_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day03Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day03Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_04_test.exs b/test/advent_of_code_2018/day_04_test.exs index ba03292..6d97a0b 100644 --- a/test/advent_of_code_2018/day_04_test.exs +++ b/test/advent_of_code_2018/day_04_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day04Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day04Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_05_test.exs b/test/advent_of_code_2018/day_05_test.exs index 7b3cb16..672df71 100644 --- a/test/advent_of_code_2018/day_05_test.exs +++ b/test/advent_of_code_2018/day_05_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day05Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day05Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_06_test.exs b/test/advent_of_code_2018/day_06_test.exs index c938392..3708715 100644 --- a/test/advent_of_code_2018/day_06_test.exs +++ b/test/advent_of_code_2018/day_06_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day06Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day06Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_07_test.exs b/test/advent_of_code_2018/day_07_test.exs index 8451ff1..e6da147 100644 --- a/test/advent_of_code_2018/day_07_test.exs +++ b/test/advent_of_code_2018/day_07_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day07Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day07Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_08_test.exs b/test/advent_of_code_2018/day_08_test.exs index b14e56d..a0f6715 100644 --- a/test/advent_of_code_2018/day_08_test.exs +++ b/test/advent_of_code_2018/day_08_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day08Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day08Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_09_test.exs b/test/advent_of_code_2018/day_09_test.exs index eb77460..dd5e422 100644 --- a/test/advent_of_code_2018/day_09_test.exs +++ b/test/advent_of_code_2018/day_09_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day09Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day09Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_10_test.exs b/test/advent_of_code_2018/day_10_test.exs index c41f928..5bf4ebd 100644 --- a/test/advent_of_code_2018/day_10_test.exs +++ b/test/advent_of_code_2018/day_10_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day10Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day10Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_11_test.exs b/test/advent_of_code_2018/day_11_test.exs index 72bb3a3..6d8f015 100644 --- a/test/advent_of_code_2018/day_11_test.exs +++ b/test/advent_of_code_2018/day_11_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day11Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day11Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_12_test.exs b/test/advent_of_code_2018/day_12_test.exs index b699fca..ea022c4 100644 --- a/test/advent_of_code_2018/day_12_test.exs +++ b/test/advent_of_code_2018/day_12_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day12Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day12Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_13_test.exs b/test/advent_of_code_2018/day_13_test.exs index bcc6c36..a044c67 100644 --- a/test/advent_of_code_2018/day_13_test.exs +++ b/test/advent_of_code_2018/day_13_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day13Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day13Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_14_test.exs b/test/advent_of_code_2018/day_14_test.exs index 9fd9675..48eb9ef 100644 --- a/test/advent_of_code_2018/day_14_test.exs +++ b/test/advent_of_code_2018/day_14_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day14Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day14Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_15_test.exs b/test/advent_of_code_2018/day_15_test.exs index 394d6d1..faee7f7 100644 --- a/test/advent_of_code_2018/day_15_test.exs +++ b/test/advent_of_code_2018/day_15_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day15Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day15Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_16_test.exs b/test/advent_of_code_2018/day_16_test.exs index 45372c1..df907e6 100644 --- a/test/advent_of_code_2018/day_16_test.exs +++ b/test/advent_of_code_2018/day_16_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day16Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day16Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_17_test.exs b/test/advent_of_code_2018/day_17_test.exs index 3d0a7a0..02da582 100644 --- a/test/advent_of_code_2018/day_17_test.exs +++ b/test/advent_of_code_2018/day_17_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day17Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day17Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_18_test.exs b/test/advent_of_code_2018/day_18_test.exs index b96018f..84b37a1 100644 --- a/test/advent_of_code_2018/day_18_test.exs +++ b/test/advent_of_code_2018/day_18_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day18Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day18Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_19_test.exs b/test/advent_of_code_2018/day_19_test.exs index d17c21e..b09e8f2 100644 --- a/test/advent_of_code_2018/day_19_test.exs +++ b/test/advent_of_code_2018/day_19_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day19Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day19Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_20_test.exs b/test/advent_of_code_2018/day_20_test.exs index 5900ab8..834ac45 100644 --- a/test/advent_of_code_2018/day_20_test.exs +++ b/test/advent_of_code_2018/day_20_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day20Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day20Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_21_test.exs b/test/advent_of_code_2018/day_21_test.exs index 642a5c5..3bc1fd3 100644 --- a/test/advent_of_code_2018/day_21_test.exs +++ b/test/advent_of_code_2018/day_21_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day21Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day21Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_22_test.exs b/test/advent_of_code_2018/day_22_test.exs index b8b59b5..b80836c 100644 --- a/test/advent_of_code_2018/day_22_test.exs +++ b/test/advent_of_code_2018/day_22_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day22Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day22Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_23_test.exs b/test/advent_of_code_2018/day_23_test.exs index e73758c..743f0bc 100644 --- a/test/advent_of_code_2018/day_23_test.exs +++ b/test/advent_of_code_2018/day_23_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day23Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day23Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_24_test.exs b/test/advent_of_code_2018/day_24_test.exs index 326920a..16c1fa1 100644 --- a/test/advent_of_code_2018/day_24_test.exs +++ b/test/advent_of_code_2018/day_24_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day24Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day24Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result diff --git a/test/advent_of_code_2018/day_25_test.exs b/test/advent_of_code_2018/day_25_test.exs index c854541..d3bfde2 100644 --- a/test/advent_of_code_2018/day_25_test.exs +++ b/test/advent_of_code_2018/day_25_test.exs @@ -5,7 +5,7 @@ defmodule AdventOfCode2019.Day25Test do @tag :skip test "part1" do - input = nil + input = nil result = part1(input) assert result @@ -13,7 +13,7 @@ defmodule AdventOfCode2019.Day25Test do @tag :skip test "part2" do - input = nil + input = nil result = part2(input) assert result -- 2.43.0