Packages

An application you can use for benchmarking, read terms from a file (or other Producer) and execute them against an anonymous function of your choice

Current section

Files

Jump to
ex_bench lib ex_bench worker.ex
Raw

lib/ex_bench/worker.ex

defmodule ExBench.Worker do
use GenServer
alias ExBench.Metrics.CommandInstrumenter
def start_link(bench_fun) do
GenServer.start_link(__MODULE__, bench_fun, [])
end
@spec init(any) :: {:ok, any}
def init(bench_fun) do
{:ok, bench_fun}
end
def handle_cast({:do_work, data}, bench_fun) do
CommandInstrumenter.counter_inc(%{command: "allocated_work"})
bench_fun.(data)
CommandInstrumenter.counter_inc(%{command: "processed_work"})
{:noreply, bench_fun}
end
end