Skip to content
forked from tidwall/lotsa

Simple Go library for executing lots of operations spread over any number of threads for a fixed duration/opCount.

License

Notifications You must be signed in to change notification settings

dborchard/lotsaa

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lotsaa

Lotsaa = Lotsa + a fixed duration execution

This package was created by forking Josh Baker's Lotsa framework.

Lotsaa supports executing an operation on several threads for i) Fixed Operation Count ii) Fixed Duration.

Install

go get -u github.com/arjunsk/lotsaa

Example 1

To run 1,000,000 operations spread over 4 threads, use lotsaa.Ops

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

Prints:

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

Example 2

To run an operation spread over 4 threads for a fixed duration, use lotsaa.Time

var total int64
lotsaa.Output = os.Stdout
lotsaa.Time(23 * time.Millisecond, 4,
    func(_ *rand.Rand, thread int) {
        atomic.AddInt64(&total, 1)
    },
)

Prints:

654,330 ops over 4 threads in 24ms, 27,207,775/sec, 36 ns/op

NOTE 1: The difference in the OPS count between lotsaa.Time and lotsaa.Ops comes from how they work inside. lotsaa.Time counts the number of operations done for that duration, but lotsaa.Ops doesn't. That's why lotsaa.Ops has more OPS numbers. So, use lotsaa.Time for comparing different data structures, not for exact measurements.

NOTE 2: This is helpful for benchmarking ephemeral data structures like Cache (maybe a combination of btree + hwt). We can measure the overall read throughput (OPS) while all the interfering actions (Reads, Writes, and Prunes) are happening.

License

Source code is available under the MIT License.

About

Simple Go library for executing lots of operations spread over any number of threads for a fixed duration/opCount.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Go 100.0%