In [28]:
using DataFrames
using Gadfly
In [29]:
# Load benchmark data from file
benchmarks = readtable("benchmarks.csv", header=false, names=[:language, :benchmark, :time])

# Capitalize and decorate language names from datafile
dict = Dict("c"=>"C", "julia"=>"Julia", "lua"=>"LuaJIT", "fortran"=>"Fortran", "java"=>"Java",
    "javascript"=>"JavaScript", "matlab"=>"Matlab", "mathematica"=>"Mathe-\nmatica", 
    "python"=>"Python", "octave"=>"Octave", "r"=>"R", "go"=>"Go")

benchmarks[:language] = [dict[lang] for lang in benchmarks[:language]]

# Normalize benchmark times by C times
ctime = benchmarks[benchmarks[:language].== "C", :]
benchmarks = join(benchmarks, ctime, on=:benchmark)
delete!(benchmarks, :language_1)
rename!(benchmarks, :time_1, :ctime)
benchmarks[:normtime] = benchmarks[:time] ./ benchmarks[:ctime];

# Compute the geometric mean for each language
langs = [];
means = [];
priorities = [];
for lang in values(dict)
    data = benchmarks[benchmarks[:language].== lang, :]
    gmean = geomean(data[:normtime])
    push!(langs, lang)
    push!(means, gmean)
    if (lang == "C")
        push!(priorities, 1)
    elseif (lang == "Julia")
        push!(priorities, 2)        
    else
        push!(priorities, 3)
    end
end

# Add the geometric means back into the benchmarks dataframe
langmean = DataFrame(language=langs, geomean = means, priority = priorities)
benchmarks = join(benchmarks, langmean, on=:language)

# Put C first, Julia second, and sort the rest by geometric mean
sort!(benchmarks, cols=[:priority, :geomean]);
In [30]:
p = plot(benchmarks,
    x = :language,
    y = :normtime,
    color = :benchmark,
    Scale.y_log10,
    Guide.ylabel(nothing),
    Guide.xlabel(nothing),
    Coord.Cartesian(xmin=1,xmax=12.3,ymin=-1,ymax=4.2),
    Theme(
        guide_title_position = :left,
        colorkey_swatch_shape = :circle,
        minor_label_font = "Georgia",
        major_label_font = "Georgia",
    ),
)
draw(SVG(8inch,8inch/golden), p)
C Julia LuaJIT Fortran Go Java JavaScript Matlab Mathe-matica Python R Octave iteration_pi_sum matrix_multiply matrix_statistics parse_integers print_to_file recursion_fibonacci recursion_quicksort userfunc_mandelbrot benchmark 10-1 100 101 102 103 104
In [31]:
draw(SVG("_includes/benchmarks.svg", 8inch, 8inch/golden), p)
Out[31]:
false
In [32]:
perm = sortperm(means)
println("cputime\tlang") 
for p in perm
    if langs[p] == "Mathe-\nmatica"
        langs[p] = "Mathematica"
    end
    @printf "%0.3f\t%s\n" means[p] langs[p]
end
cputime	lang
1.000	C
1.093	Julia
1.109	LuaJIT
1.496	Fortran
1.511	Go
2.745	Java
3.448	JavaScript
12.790	Matlab
14.121	Mathematica
16.610	Python
70.955	R
575.269	Octave