STL benchmark comparing C++ and Julia ⏱
For more information: STL Benchmark Comparison: C++ vs. Julia.
$ git clone --recurse-submodules [email protected]:aaronang/stl-benchmark.git
From the cpp
directory:
$ export CC=/usr/bin/clang
$ export CXX=/usr/bin/clang++
$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..
$ make -j
$ ./stl_benchmark
2018-10-06 12:35:31
Running ./stl_benchmark
Run on (8 X 2300 MHz CPU s)
CPU Caches:
L1 Data 32K (x4)
L1 Instruction 32K (x4)
L2 Unified 262K (x4)
L3 Unified 6291K (x1)
--------------------------------------------------
Benchmark Time CPU Iterations
--------------------------------------------------
ParseStl 429234 ns 409210 ns 1729
From the julia
directory:
$ julia -O3
julia> ]
(v1.0) pkg> activate .
(benchmark) pkg> ^C
julia> using BenchmarkTools
julia> include("stl.jl")
julia> @btime STL.parse("nist.stl")
211.641 μs (9 allocations: 347.06 KiB)
From the python
directory:
$ python benchmark.py
25150.930999999986 μs
Note: Python 3.7.0 is required.
Language | Time |
---|---|
C++ | 409.210 μs |
Julia | 211.641 μs |
Python | 25150.9 μs |
I am neither a C++ nor Julia expert. Please let me know if I biased the results by implementing something obviously inefficiently.