the beginning of bringing benchee back

This commit is contained in:
Tristan Sloughter 2022-11-06 10:50:42 -07:00
parent 94a992ea00
commit 8a0441356d
No known key found for this signature in database
GPG Key ID: 6BC93CF674613287
6 changed files with 41 additions and 11 deletions

View File

@ -176,15 +176,16 @@ it is included the override is necessary.
Running benchmarks is done with [benchee](https://github.com/bencheeorg/benchee). Benchmark functions are in modules under `samples/`. To run them open a rebar3 shell in the `bench` profile:
``` shell
$ rebar3 as bench compile
$ rebar3 as bench shell
> otel_benchmarks:run().
```
If an Elixir script is wanted for the benchmarks they could be run like:
If an Elixir script is wanted for the benchmarks they could be run like (after
running `rebar3 as bench compile`):
``` shell
$ ERL_LIBS=_build/bench/lib/ mix run --no-mix-exs samples/run.exs
$ ERL_AFLAGS="-pa ./_build/bench/extras/samples/" ERL_LIBS=_build/bench/lib/ mix run --no-mix-exs samples/run.exs
```
## W3C Trace Context Interop Tests

7
config/bench.config Normal file
View File

@ -0,0 +1,7 @@
[
{opentelemetry,
[{processors, [{otel_batch_processor,
#{exporter => none}
}]
}]}
].

View File

@ -1,7 +1,3 @@
[
{opentelemetry,
[{processors, [{otel_batch_processor,
#{exporter => {otel_exporter_stdout, []}}
}]
}]}
{opentelemetry, []}
].

View File

@ -29,9 +29,13 @@
{extra_src_dirs, ["interop"]}]},
{bench, [{deps, [benchee]},
{extra_src_dirs, ["bench"]},
{extra_src_dirs, ["samples"]},
{plugins, [rebar_mix]},
{provider_hooks, [{pre, [{compile, {mix, find_elixir_libs}}]}]}]}]}.
{provider_hooks, []},
{shell, [{apps, [opentelemetry,
opentelemetry_experimental]},
{config, "config/bench.config"}]}]}]}.
{xref_checks, [undefined_function_calls, undefined_functions, locals_not_used,
deprecated_function_calls, deprecated_functions]}.

View File

@ -0,0 +1,22 @@
-module(otel_benchmarks).
-export([run/0]).
-include_lib("opentelemetry_api/include/otel_tracer.hrl").
%% doesn't currently show anything useful
run() ->
PDictCtxFun = fun() ->
?start_span(a_span),
?end_span()
end,
CtxFun = fun() ->
Tracer = opentelemetry:get_application_tracer(?MODULE),
SpanCtx = otel_tracer:start_span(Tracer, a_span, #{}),
otel_span:end_span(SpanCtx)
end,
benchee:run(#{<<"pdict_ctx">> => PDictCtxFun,
<<"ctx">> => CtxFun}),
ok.

View File

@ -1,4 +1,4 @@
# this file makes it possible to run the benchmarks in CI
# with `mix run`
:ot_benchmarks.run()
:otel_benchmarks.run()