lotsa

package
v0.0.0-...-642df0c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2024 License: BSD-3-Clause, MIT Imports: 5 Imported by: 0

README

lotsa

Lotsa is a simple Go library for executing lots of operations spread over any number of threads.

Install

go get -u github.com/tidwall/lotsa

Example

Here we load 1,000,000 operations spread over 4 threads.

var total int64
lotsa.Ops(1000000, 4,
    func(i, thread int) {
        atomic.AddInt64(&total, 1)
    },
)
println(total)

Prints 1000000

To output some benchmarking results, set the lotsa.Output prior to calling lotsa.Ops

var total int64
lotsa.Output = os.Stdout
lotsa.Ops(1000000, 4,
    func(i, thread int) {
        atomic.AddInt64(&total, 1)
    },
)

Prints:

1,000,000 ops over 4 threads in 23ms, 43,580,037/sec, 22 ns/op

Contact

Josh Baker @tidwall

License

Source code is available under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MemUsage bool

MemUsage is used to output the memory usage

View Source
var Output io.Writer

Output is used to print elased time and ops/sec

Functions

func Ops

func Ops(count, threads int, op func(i, thread int))

Ops executed a number of operations over a multiple goroutines. count is the number of operations. threads is the number goroutines. op is the operation function

func WriteOutput

func WriteOutput(w io.Writer, count, threads int, elapsed time.Duration, alloc uint64)

WriteOutput writes an output line to the specified writer

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL