using BenchmarkLite type VecMath{Op} <: Proc end type Sqrt end calc(::Sqrt, x) = sqrt(x) type Exp end calc(::Exp, x) = exp(x) type Log end calc(::Log, x) = log(x); Base.string{Op}(::VecMath{Op}) = string("vec-", lowercase("$Op")); string(VecMath{Sqrt}()) typealias FVecPair (Vector{Float64},Vector{Float64}); Base.length(p::VecMath, n::Int) = n Base.isvalid(p::VecMath, n::Int) = (n > 0) Base.start(p::VecMath, n::Int) = (rand(n), zeros(n)) function Base.run{Op}(p::VecMath{Op}, n::Int, s::FVecPair) x, y = s op = Op() for i = 1:n @inbounds y[i] = calc(op, x[i]) end end Base.done(p::VecMath, n, s) = nothing; procs = Proc[ VecMath{Sqrt}(), VecMath{Exp}(), VecMath{Log}() ]; cfgs = 2 .^ (4:10) rtable = run(procs, cfgs); show(rtable; unit=:msec) show(rtable; unit=:usec) show(rtable; unit=:mps)