Simon Danisch / Feb 18 2019

BenchmarkGame

apt-get update
apt-get install libgmp3-dev libapr1 libapr1-dev g++ libpcre3 libpcre3-dev git -y
pkg"add PackageCompiler"
git clone https://github.com/SimonDanisch/BenchmarksGame.jl BenchmarksGame
cd BenchmarksGame
git checkout sd-cppbench
git pull origin sd-cppbench
cd("/BenchmarksGame/cpp_src")
run(`julia make.jl`)
# make julia
cd("/BenchmarksGame/jl_build")
run(`julia make.jl`)
length(filter(x-> !occursin(".", x), readdir("/BenchmarksGame/cpp_src"))) == 10
length(filter(x-> !occursin(".", x), readdir("/BenchmarksGame/jl_build/image"))) == 10
cd("/BenchmarksGame/")
fasta_input = "fasta.txt"
fasta_gen = joinpath("fasta", "fasta.jl")
if !isfile(fasta_input)
	run(pipeline(`$(Base.julia_cmd()) $fasta_gen 25000000` ;stdout = fasta_input))
end
fasta_input = "fasta.txt"
benchmarks = [
    ("binarytrees", 21),
    ("fannkuchredux", 12),
    ("fasta", 25000000),
    ("knucleotide", fasta_input),
    ("mandelbrot", 16000),
    ("nbody", 50000000),
    ("pidigits", 10000),
    ("regexredux", fasta_input),
    ("revcomp", fasta_input),
    ("spectralnorm", 5500),
]
dir = "/BenchmarksGame"
cd(dir)
results = map(benchmarks) do (bench, arg)
  println(bench)
  args = [:stdout => "result.bin"]
  argcmd = ``
  cmd = if arg isa String
    push!(args, :stdin => arg)
  else
    argcmd = `$arg`
  end
  res = map(1:10) do i
    ctime = @elapsed run(pipeline(`./cpp_src/$bench $argcmd`; args...))
    jltime = withenv("JULIA_NUM_THREADS" => 16) do
       @elapsed run(pipeline(`./jl_build/image/$bench $argcmd`; args...))
    end
    (jltime, ctime)
  end
  bench => res
end
results
using Serialization
open("/results/c_vs_julia.jls", "w") do io
  serialize(io, results)
end
c_vs_julia.jls
mini = map(x-> (minimum(first.(x)), minimum(last.(x))), last.(results))
using Statistics

mean(first.(mini) ./ last.(mini))
not_optimized = [3, 4, 7, 8]
idx = [!(i in not_optimized) for i in 1:10]
mean(first.(mini[idx]) ./ last.(mini[idx]))