FnLoadTester

hex.pmhexdocs.pmBuild Status

FnLoadTester is a helper tool to execute load tests against your functions, especially your GenServers, and calculate statistics of the test.

Installation

If available in Hex, the package can be installed by adding fn_load_tester to your list of dependencies in mix.exs:

def deps do
  [
    {:fn_load_tester, "~> 0.1.0", only: :dev}
  ]
end

Stats

FnLoadTester brings some basic statistics but it also gives you the possibility of adding your own statistics.

To Build a new Stats it is only necessary to use FnLoadTester.Stats and implement the callbacks:

In order to have more information, check the module FnLoadTester.Stats

Execution

In order to execute the load test you only have to specify the number of parallel clients that will execute the given function and the number of requests per client. The fourth argument (optional) is the statistics that will be calculated.

    iex> FnLoadTester.request(1, 100, fn -> MyGenServer.execute() end)
    Maximum:                104610  ns
    Minimum:                20123   ns
    Average:                26940   ns
    Percentile50:           21877   ns
    Percentile90:           36460   ns
    Percentile95:           50784   ns
    Percentile99:           104610  ns
    :ok
    iex> FnLoadTester.request(1, 100, fn -> MyGenServer.execute() end, [FnLoadTester.Stats.Maximum, FnLoadTester.Stats.Minimum])
    Maximum:                104610  ns
    Minimum:                20123   ns
    :ok

Test

  mix test