changed CHANGELOG.md
 
@@ -2,6 +2,19 @@
2
2
3
3
<!-- %% CHANGELOG_ENTRIES %% -->
4
4
5
+ ### 0.5.0 - 2024-05-11 10:55:28
6
+
7
+ The user can now specify the directory where the HTML files will be saved.
8
+
9
+ Incendium used to fail if the user tried to profile memory.
10
+ After a simple fix, it doesn't fail anymore.
11
+ Memory usage is reported in the console output, but not in the HTML report page yet.
12
+
13
+ Dependencies have now been streamlined.
14
+
15
+ Added some simple end-to-end tests.
16
+
17
+
5
18
### 0.4.0 - 2023-07-05 08:15:39
6
19
7
20
Remove support for interactive usage in Phoenix applications.
changed hex_metadata.config
 
@@ -27,8 +27,7 @@
27
27
<<"lib/incendium/assets/vendor/d3-tip.js">>,
28
28
<<"lib/incendium/assets/vendor/flamegraph.css">>,
29
29
<<"lib/incendium/assets/vendor/bootstrap.js">>,
30
- <<"lib/incendium/application.ex">>,<<"lib/incendium/view.ex">>,
31
- <<"lib/incendium/benchee.ex">>,
30
+ <<"lib/incendium/application.ex">>,<<"lib/incendium/benchee.ex">>,
32
31
<<"lib/incendium/benchee_formatter_data.ex">>,
33
32
<<"lib/incendium/benchee_formatter_common.ex">>,<<"lib/mix">>,
34
33
<<"lib/mix/incendium.assets.ex">>,<<"lib/mix/incendium.build_assets.ex">>,
 
@@ -54,7 +53,7 @@
54
53
{<<"name">>,<<"benchee">>},
55
54
{<<"optional">>,false},
56
55
{<<"repository">>,<<"hexpm">>},
57
- {<<"requirement">>,<<"~> 1.0">>}],
56
+ {<<"requirement">>,<<"~> 1.3">>}],
58
57
[{<<"app">>,<<"slugify">>},
59
58
{<<"name">>,<<"slugify">>},
60
59
{<<"optional">>,false},
 
@@ -64,15 +63,10 @@
64
63
{<<"name">>,<<"phoenix_html">>},
65
64
{<<"optional">>,false},
66
65
{<<"repository">>,<<"hexpm">>},
67
- {<<"requirement">>,<<"~> 3.0">>}],
68
- [{<<"app">>,<<"phoenix">>},
69
- {<<"name">>,<<"phoenix">>},
70
- {<<"optional">>,false},
71
- {<<"repository">>,<<"hexpm">>},
72
- {<<"requirement">>,<<"~> 1.7">>}],
66
+ {<<"requirement">>,<<"~> 4.0">>}],
73
67
[{<<"app">>,<<"jason">>},
74
68
{<<"name">>,<<"jason">>},
75
69
{<<"optional">>,false},
76
70
{<<"repository">>,<<"hexpm">>},
77
71
{<<"requirement">>,<<"~> 1.2">>}]]}.
78
- {<<"version">>,<<"0.4.0">>}.
72
+ {<<"version">>,<<"0.5.0">>}.
changed lib/incendium/benchee.ex
 
@@ -3,19 +3,35 @@ defmodule Incendium.Benchee do
3
3
4
4
alias Incendium.BencheeServer
5
5
6
+ @default_benchmark_directory "incendium"
7
+
6
8
@doc """
7
9
TODO:
10
+
11
+ Options:
12
+
13
+ * `:title` (*required*) - a title for the benchmark suite
14
+ * `:benchmark_directory` (*string, optional* - default: `"incendium"`) -
15
+ the directory where the HTML files generated by Incendium will be stored.
16
+ * `:incendium_flamegraph_widths_to_scale` (*boolean, optional*) -
17
+ whether to scale the flamegraph widths according to the runtime
18
+ of the tests. Default: `false`.
8
19
"""
9
20
def run(benchmarks, options) do
10
21
suite_name = Keyword.fetch!(options, :title)
22
+
11
23
{incendium_flamegraph_widths_to_scale, options} =
12
24
Keyword.pop(options, :incendium_flamegraph_widths_to_scale, false)
13
25
26
+ {benchmarks_directory, options} =
27
+ Keyword.pop(options, :benchmark_directory, @default_benchmark_directory)
28
+
14
29
# Run the original suite so that we get runtimes not affected by the profiler.
15
30
original_suite = Benchee.run(benchmarks, options)
16
31
17
32
# After running the original suite, we'll run a suite in which all function
18
33
# executions are wrapped by the profiler.
34
+ #
19
35
# We can compare the runtime of the scenarios from both suites to see if
20
36
# runtimes of different scenarios remain proportional.
21
37
# This is a useful sanity check because tracing profilers may distort
 
@@ -27,12 +43,20 @@ defmodule Incendium.Benchee do
27
43
incendium_formatter =
28
44
{Incendium.BencheeHtmlFormatter, [
29
45
original_suite: original_suite,
30
- flamegraph_scale_widths: incendium_flamegraph_widths_to_scale
46
+ flamegraph_scale_widths: incendium_flamegraph_widths_to_scale,
47
+ benchmarks_directory: benchmarks_directory
31
48
]}
32
49
33
- # We don't want any of the default formatters here;
34
- # They'd be operating on wrong data (data "contaminated" by the profiler)
35
- options_for_profiling = Keyword.put(options, :formatters, [incendium_formatter])
50
+ # We don't want any of the default formatters here.
51
+ # They'd be operating on wrong data (data "contaminated" by the profiler).
52
+ # We also don't want to profile memory here, because:
53
+ # 1) incendium can't handle it yet
54
+ # 2) flamegraphs don't make much sense when profiling memory instead of runtime
55
+
56
+ options_for_profiling =
57
+ options
58
+ |> Keyword.put(:memory_time, 0)
59
+ |> Keyword.put(:formatters, [incendium_formatter])
36
60
37
61
38
62
benchmarks_for_profiling = prepare_benchmarks_for_profiling(suite_name, benchmarks)
changed lib/incendium/benchee_html_formatter.ex
 
@@ -35,6 +35,8 @@ defmodule Incendium.BencheeHtmlFormatter do
35
35
36
36
@impl true
37
37
def write(formatter_data = %BencheeFormatterData{}, options) do
38
+ benchmarks_directory = Map.fetch!(options, :benchmarks_directory)
39
+
38
40
%{incendium_suite: incendium_suite,
39
41
incendium_scenarios_data: incendium_scenarios_data,
40
42
original_suite: original_suite,
 
@@ -49,7 +51,7 @@ defmodule Incendium.BencheeHtmlFormatter do
49
51
original_scaling_strategy = original_config.unit_scaling
50
52
original_units = Conversion.units(original_suite.scenarios, original_scaling_strategy)
51
53
52
- default_file = Path.join("incendium", incendium_suite.configuration.title <> ".html")
54
+ default_file = Path.join(benchmarks_directory, incendium_suite.configuration.title <> ".html")
53
55
file = Map.get(options, :incendium_file, default_file)
54
56
_embed = Map.get(options, :embed, true)
55
57
flamegraph_widths_to_scale = Map.get(options, :incendium_flamegraph_widths_to_scale, true)
removed lib/incendium/view.ex
 
@@ -1,18 +0,0 @@
1
- defmodule Incendium.View do
2
- @moduledoc false
3
-
4
- # Helpers to render pages in the IncendiumController.
5
-
6
- alias Incendium.Assets
7
-
8
- @external_resource "#{__DIR__}/templates/view/latest-flamegraph.html.eex"
9
- @external_resource "#{__DIR__}/templates/view/flamegraph.js.eex"
10
-
11
- use Phoenix.Template,
12
- root: "#{__DIR__}/templates/view",
13
- path: ""
14
-
15
- def extra_css() do
16
- Assets.extra_css()
17
- end
18
- end
changed mix.exs
 
@@ -1,7 +1,7 @@
1
1
defmodule Incendium.MixProject do
2
2
use Mix.Project
3
3
4
- @version "0.4.0"
4
+ @version "0.5.0"
5
5
@url "https://github.com/tmbb/incendium"
6
6
7
7
def project do
 
@@ -48,15 +48,14 @@ defmodule Incendium.MixProject do
48
48
49
49
# Dependencies required for benchmarks:
50
50
{:size, "~> 0.1"},
51
- {:benchee, "~> 1.0"},
51
+ {:benchee, "~> 1.3"},
52
52
# TODO: do we really need slugify?
53
53
{:slugify, "~> 1.3"},
54
54
55
55
# Dependencies required for both Phoenix applications and benchmarks:
56
- # NOTE: `phoenix_html` is NOT phoenix-specific.
56
+ # NOTE: `phoenix_view` is NOT phoenix-specific.
57
57
# It merely provides utilities to work with HTML templates
58
- {:phoenix_html, "~> 3.0"},
59
- {:phoenix, "~> 1.7"},
58
+ {:phoenix_html, "~> 4.0"},
60
59
{:jason, "~> 1.2"},
61
60
62
61
# Documentation