Giter Club home page Giter Club logo

emark's Introduction

emark

Lightweight benchmarking framework for Erlang.

It is a plugin for rebar which benchmarks your code.

What it looks like

==> bench0 (emark)
calc_something/0	20000	38.1 µs/op
parse_omg_wtf/1	500000	1.6 µs/op

benchmark                      old µs/op new µs/op   delta
calc_something/0                    37.7      38.0  +0.79%
parse_omg_wtf/1                      1.6       1.5  -6.67%

Usage example

There is an example in examples/bench0 subdirectory.

cd examples/bench0
mkdir -p deps
ln -s `pwd`/../../ deps/emark
../../rebar compile
../../rebar emark

Details

emark works almost like eunit.

-include_lib("emark/include/emark.hrl").

-ifdef(BENCHMARK).

my_function_benchmark(N) ->
  Input = prepare_n_inputs(N),
  emark:start(?MODULE, my_function, 1),
  lists:seq(fun(E) -> _ = my_function(E) end, Input).

-endif.

The main difference is the emark:start call. It starts tracing the specified function, so it then knows how many times it was really called while benchmark was run. It also starts the actual timer, so preparation should be done before calling it.

emark prints benchmark results to the terminal. First column is the name of the function and its arity, second column is the number of iterations during the benchmark, thirs column is the average time it took the function to run (microseconds).

By default, emark also saves a report to a file under .emark/ directory. It's used on next run to show a difference between runs. So the idea behind emark is that you run benchmark (rebar emark), then change the code of some important function, and rerun benchmark to see if anything went better (or worse).

emark's People

Contributors

ftrvxmtrx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.