Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

BenchmarkIps

Build Status Hex docs Hex Version License

Warning: this is a work-in-progress by someone learning Elixir and has not been reviewed by anyone who knows what they're doing.

BenchmarkIps benchmarks a function and returns how many iterations it can run per second (in wall time). This saves you from having to guess how many times to run something in order to get a meaningful benchmark.

This library is inspired by Evan Phoenix's Ruby library benchmark-ips.

Installation

Add BenchmarkIps to your mix.exs file:

defp deps do
  [
    # ...
    { :benchmark_ips, "~> 0.2.0" },
  ]
end

Then run mix deps.get to fetch everything.

Usage

Pass in a function to BenchmarkIps.report and it will return {iterations_per_second, microseconds_per_iteration}:

iex> BenchmarkIps.report(fn -> :timer.sleep(1_000) end)
{0.9952333299661271, 1004789.5000000001}

You can also specify how long the warmup time and bench time should be (below are the defaults, in seconds):

BenchmarkIps.report(fn -> :timer.sleep(1_000) end, warmup_time_s: 1, bench_time_s: 2)

Example

An example is included in examples/list_bench.exs that compares various operations on lists and tuples.

See examples/list_bench.md for the output it generates.

About

Iteration per second benchmarking for Elixir

Resources

License

Packages

No packages published

Languages