https://github.com/tidwall/lotsa
Simple Go library for executing lots of operations spread over any number of threads
https://github.com/tidwall/lotsa
Last synced: 8 months ago
JSON representation
Simple Go library for executing lots of operations spread over any number of threads
- Host: GitHub
- URL: https://github.com/tidwall/lotsa
- Owner: tidwall
- License: mit
- Created: 2018-01-08T00:47:59.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-05-25T08:00:57.000Z (over 2 years ago)
- Last Synced: 2025-05-08T23:45:43.518Z (8 months ago)
- Language: Go
- Size: 11.7 KB
- Stars: 73
- Watchers: 6
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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.
```go
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`
```go
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](http://twitter.com/tidwall)
## License
Source code is available under the MIT [License](/LICENSE).