An open API service indexing awesome lists of open source software.

https://github.com/juliaastrosim/benchmarkplots.jl


https://github.com/juliaastrosim/benchmarkplots.jl

Last synced: 11 months ago
JSON representation

Awesome Lists containing this project

README

          

# BenchmarkPlots.jl

Benchmark functions with different amount of data and plot in one figure.

[![codecov](https://codecov.io/gh/JuliaAstroSim/BenchmarkPlots.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaAstroSim/BenchmarkPlots.jl)

## Install

In `Julia` `REPL`
```julia
]add BenchmarkPlots
```

## Usage

### Basic

```julia
using BenchmarkTools, Makie
fig, df = benchmarkplot(
[sum, minimum],
rand,
[10^i for i in 1:4],
)
display(fig)
display(df)
Makie.save("benchmark_sum_miminum.png", fig)
```

![](./doc/figs/benchmark_sum_miminum.png)

### More info

```julia
help?> benchmarkplot
search: benchmarkplot benchmarkplot! BenchmarkPlots benchmark BenchmarkTools

benchmarkplot(Functions::Array, Names::Array, gen::Union{Function,Array}, NumData::Array; kw...)

Benchmark multiple Functions using different lengths of data generated by function gen. NumData is an Array or other iteratables. Returns a
Tuple of (fig, df).

Core Algorithm
≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡

For each element in NumData:

1. gen generates data with length corresponded

2. BenchmarkTools.@benchmark tunes each function in Functions and restore timings in an array

3. Plot figure

Keywords
≡≡≡≡≡≡≡≡≡≡

• title: figure title. Default is "Benchmark"

• logscale: If true, plot axes in log10 scale. Default is true.

• xlabel: label of x-axis. Default is logscale ? "log10(N)" : "N"

• ylabel: label of y-axis. Default is logscale ? "log10(Timing [ns])" : "Timing [ns]"

• resolution: figure resolution. Default is (1600, 900)

• Names: alternative names of testing functions. Default is string.(Functions), which is exactly the same with function names

• colors: colors of each benchmark line. Default is nothing, meaning random colors are assigned to lines.

• savelog::Bool: If true, save processed data in csv. The name of logging file depends on analysis function

• savefolder: set the directory to save logging file

• stairplot: If true, plot line in stair style (which is more concrete). Default is true

• legend: If tree, add legend to the plot

• loadfromfile: Path to the file of benchmark result. If nothing, run a new benchmark.

Examples
≡≡≡≡≡≡≡≡≡≡

using BenchmarkPlots, Makie
fig, df = benchmarkplot(
[sum, minimum],
rand,
[10^i for i in 1:4],
)
display(fig)
display(df)
Makie.save("benchmark_sum_miminum.png", fig)
```