Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PlotMemory ¶
func PlotMemory(title, xLabel string, results *benchkit.MemResult, logscale bool) (*plot.Plot, error)
PlotMemory will create a line graph of AfterEach measurements. The lines plotted are:
current heap size : HeapAlloc total heap size : HeapSys memory allocated from OS : Sys effective memory consumption : Sys - HeapReleased
The Y axis is implicitely measured in Bytes.
Example ¶
n := 100 size := int(1e6) buf := bytes.NewBuffer(nil) memkit, results := benchkit.Memory(n) memkit.Setup() files := GenTarFiles(n, size) memkit.Starting() each := memkit.Each() buf.Reset() tarw := tar.NewWriter(buf) for j, file := range files { each.Before(j) _ = tarw.WriteHeader(file.TarHeader()) _, _ = tarw.Write(file.Data()) each.After(j) } _ = tarw.Close() memkit.Teardown() p, _ := PlotMemory( fmt.Sprintf("archive/tar memory usage for %d files, %s each", n, humanize.Bytes(uint64(size))), "Files in archive", results, false, ) _ = p.Save(960, 720, "tar_memplot.svg")
Output:
Example (Bench) ¶
n := 100 size := int(1e6) buf := bytes.NewBuffer(nil) files := GenTarFiles(n, size) results := benchkit.Bench(benchkit.Memory(n)).Each(func(each benchkit.BenchEach) { buf.Reset() tarw := tar.NewWriter(buf) for j, file := range files { each.Before(j) _ = tarw.WriteHeader(file.TarHeader()) _, _ = tarw.Write(file.Data()) each.After(j) } _ = tarw.Close() }).(*benchkit.MemResult) p, _ := PlotMemory( fmt.Sprintf("archive/tar memory usage for %d files, %s each", n, humanize.Bytes(uint64(size))), "Files in archive", results, false, ) _ = p.Save(960, 720, "tar_memplot.png")
Output:
func PlotTime ¶
func PlotTime(title, xLabel string, results *benchkit.TimeResult, logscale bool) (*plot.Plot, error)
PlotTime does stuff.
Example ¶
n := 100 times := 100 size := int(1e6) buf := bytes.NewBuffer(nil) timekit, results := benchkit.Time(n, times) timekit.Setup() files := GenTarFiles(n, size) timekit.Starting() each := timekit.Each() for i := 0; i < times; i++ { buf.Reset() tarw := tar.NewWriter(buf) for j, file := range files { each.Before(j) _ = tarw.WriteHeader(file.TarHeader()) _, _ = tarw.Write(file.Data()) each.After(j) } _ = tarw.Close() } timekit.Teardown() p, _ := PlotTime( fmt.Sprintf("archive/tar time usage for %d files, %s each, over %d measurements", n, humanize.Bytes(uint64(size)), times), "Files in archive", results, true, ) _ = p.Save(960, 720, "tar_timeplot.svg")
Output:
Example (Bench) ¶
n := 100 times := 100 size := int(1e6) buf := bytes.NewBuffer(nil) files := GenTarFiles(n, size) results := benchkit.Bench(benchkit.Time(n, times)).Each(func(each benchkit.BenchEach) { for repeat := 0; repeat < times; repeat++ { buf.Reset() tarw := tar.NewWriter(buf) for j, file := range files { each.Before(j) _ = tarw.WriteHeader(file.TarHeader()) _, _ = tarw.Write(file.Data()) each.After(j) } _ = tarw.Close() } }).(*benchkit.TimeResult) p, _ := PlotTime( fmt.Sprintf("archive/tar time usage for %d files, %s each, over %d measurements", n, humanize.Bytes(uint64(size)), times), "Files in archive", results, true, ) _ = p.Save(960, 720, "tar_timeplot.png")
Output:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.