All Projects → valyala → Fastrand

valyala / Fastrand

Licence: mit
Fast and scalable pseudorandom generator for Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Fastrand

Bazel
a fast, scalable, multi-language and extensible build system
Stars: ✭ 17,790 (+14481.97%)
Mutual labels:  scalable, fast
litchi
这是一款分布式的java游戏服务器框架
Stars: ✭ 97 (-20.49%)
Mutual labels:  fast, scalable
Fero
light, fast, scalable, streaming microservices made easy
Stars: ✭ 175 (+43.44%)
Mutual labels:  scalable, fast
Spout
Read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way
Stars: ✭ 3,861 (+3064.75%)
Mutual labels:  scalable, fast
Containers
Containers backed by std.experimental.allocator
Stars: ✭ 111 (-9.02%)
Mutual labels:  fast
Borm
【🔥今日热门】🏎️ 更好的ORM库 (Better ORM library that is simple, fast and self-mockable for Go)
Stars: ✭ 102 (-16.39%)
Mutual labels:  fast
Geotic
Entity Component System library for javascript
Stars: ✭ 97 (-20.49%)
Mutual labels:  fast
Koa Tree Router
high performance router for Koa
Stars: ✭ 97 (-20.49%)
Mutual labels:  fast
Crepe
The thin API stack.
Stars: ✭ 120 (-1.64%)
Mutual labels:  fast
Duckstation
Fast PlayStation 1 emulator for x86-64/AArch32/AArch64
Stars: ✭ 2,888 (+2267.21%)
Mutual labels:  fast
Delaunator
An incredibly fast JavaScript library for Delaunay triangulation of 2D points
Stars: ✭ 1,641 (+1245.08%)
Mutual labels:  fast
Mapster
A fast, fun and stimulating object to object Mapper
Stars: ✭ 1,375 (+1027.05%)
Mutual labels:  fast
React Fast Charts
Blazing Fast Charting Library in React with loading time less than 50ms
Stars: ✭ 113 (-7.38%)
Mutual labels:  fast
Cn sort
中文排序:按拼音/笔顺快速排序简体中文词组(百万数量级,可含中英/多音字)。如果对您有所帮助,欢迎点个star鼓励一下。
Stars: ✭ 102 (-16.39%)
Mutual labels:  fast
Moodle Downloader 2
A Moodle downloader that downloads course content fast from Moodle (eg. lecture pdfs)
Stars: ✭ 118 (-3.28%)
Mutual labels:  fast
Wg Install
Wireguard road warrior installer for Ubuntu, Debian, CentOS and Fedora
Stars: ✭ 99 (-18.85%)
Mutual labels:  fast
Griddb
GridDB is a next-generation open source database that makes time series IoT and big data fast,and easy.
Stars: ✭ 1,587 (+1200.82%)
Mutual labels:  fast
Legacy
[Deprecated] Nano-framework for Node.js. Use PRO version
Stars: ✭ 117 (-4.1%)
Mutual labels:  fast
Node Cache
a node internal (in-memory) caching module
Stars: ✭ 1,660 (+1260.66%)
Mutual labels:  fast
Structlinq
Implementation in C# of LINQ concept with struct
Stars: ✭ 106 (-13.11%)
Mutual labels:  fast

Build Status GoDoc Go Report

fastrand

Fast pseudorandom number generator.

Features

  • Optimized for speed.
  • Performance scales on multiple CPUs.

How does it work?

It abuses sync.Pool for maintaining "per-CPU" pseudorandom number generators.

TODO: firgure out how to use real per-CPU pseudorandom number generators.

Benchmark results

$ GOMAXPROCS=1 go test -bench=. github.com/valyala/fastrand
goos: linux
goarch: amd64
pkg: github.com/valyala/fastrand
BenchmarkUint32n                   	50000000	        29.7 ns/op
BenchmarkRNGUint32n                	200000000	         6.50 ns/op
BenchmarkRNGUint32nWithLock        	100000000	        21.5 ns/op
BenchmarkMathRandInt31n            	50000000	        31.8 ns/op
BenchmarkMathRandRNGInt31n         	100000000	        17.9 ns/op
BenchmarkMathRandRNGInt31nWithLock 	50000000	        30.2 ns/op
PASS
ok  	github.com/valyala/fastrand	10.634s
$ GOMAXPROCS=2 go test -bench=. github.com/valyala/fastrand
goos: linux
goarch: amd64
pkg: github.com/valyala/fastrand
BenchmarkUint32n-2                     	100000000	        17.6 ns/op
BenchmarkRNGUint32n-2                  	500000000	         3.36 ns/op
BenchmarkRNGUint32nWithLock-2          	50000000	        32.0 ns/op
BenchmarkMathRandInt31n-2              	20000000	        51.2 ns/op
BenchmarkMathRandRNGInt31n-2           	100000000	        11.0 ns/op
BenchmarkMathRandRNGInt31nWithLock-2   	20000000	        91.0 ns/op
PASS
ok  	github.com/valyala/fastrand	9.543s
$ GOMAXPROCS=4 go test -bench=. github.com/valyala/fastrand
goos: linux
goarch: amd64
pkg: github.com/valyala/fastrand
BenchmarkUint32n-4                     	100000000	        14.2 ns/op
BenchmarkRNGUint32n-4                  	500000000	         3.30 ns/op
BenchmarkRNGUint32nWithLock-4          	20000000	        88.7 ns/op
BenchmarkMathRandInt31n-4              	10000000	       145 ns/op
BenchmarkMathRandRNGInt31n-4           	200000000	         8.35 ns/op
BenchmarkMathRandRNGInt31nWithLock-4   	20000000	       102 ns/op
PASS
ok  	github.com/valyala/fastrand	11.534s

As you can see, fastrand.Uint32n scales on multiple CPUs, while rand.Int31n doesn't scale. Their performance is comparable on GOMAXPROCS=1, but fastrand.Uint32n runs 3x faster than rand.Int31n on GOMAXPROCS=2 and 10x faster than rand.Int31n on GOMAXPROCS=4.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].