Comparing benchmarks



Assume two functions f and g whose relative performance
I would like to determine.

@time f(100) -> f_sec (f_alloc: f_mem)
@time g(100) -> g_sec (f_alloc: f_mem)

I would like to have a macro which gives me

@relperf f(100), g(100) -> (f_sec/g_sec, f_alloc/g_alloc, f_mem/g_mem)

It is beyond my knowledge to write such a macro.
Maybe someone is willing to give it away?


The link points to the ratio and judge functions in the docs.


Have you seen the @timed macro?

help?> @timed

  A macro to execute an expression, and return the value of the expression,
  elapsed time, total bytes allocated, garbage collection time, and an object
  with various memory allocation counters.

  See also @time, @timev, @elapsed, and @allocated.

  julia> val, t, bytes, gctime, memallocs = @timed rand(10^6);
  julia> t
  julia> bytes
  julia> gctime
  julia> fieldnames(typeof(memallocs))
  9-element Array{Symbol,1}:
  julia> memallocs.total_time

Edit I just saw what Elrod wrote, lol. Definitely use BenchmarkTools for more accurate benchmarks, because they deal with warm up time and they average times as well.