Skip to content

Instantly share code, notes, and snippets.

View flyingmutant's full-sized avatar

Gregory Petrosyan flyingmutant

View GitHub Profile
@flyingmutant
flyingmutant / bench.txt
Last active June 22, 2023 17:25
Lemire's algorithm vs fixed-point multiplication
goos: linux
goarch: amd64
pkg: rand
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
BenchmarkUint32n/fp/small-8 721959876 1.586 ns/op
BenchmarkUint32n/fp/midrange-8 886869387 1.376 ns/op
BenchmarkUint32n/fp/big-8 843097094 1.520 ns/op
BenchmarkUint32n/fp/rand-8 565216611 2.137 ns/op
BenchmarkUint32n/lemire/small-8 474396974 3.189 ns/op
BenchmarkUint32n/lemire/midrange-8 472477327 3.216 ns/op
@flyingmutant
flyingmutant / practrand-fastrand-Uint64.txt
Created August 6, 2022 13:03
Testing Go's github.com/valyala/fastrand with PractRand (using https://github.com/flyingmutant/rand/tree/master/misc/practrand)
> ./practrand -gen=x-fast | PractRand stdin64 -multithreaded
RNG_test using PractRand version 0.95
RNG = RNG_stdin64, seed = unknown
test set = core, folding = standard (64 bit)
rng=RNG_stdin64, seed=unknown
length= 1 gigabyte (2^30 bytes), time= 3.7 seconds
Test Name Raw Processed Evaluation
BCFN(2+0,13-1,T) R=+217.8 p = 9.2e-117 FAIL !!!!!
BCFN(2+1,13-1,T) R= +47.8 p = 3.4e-25 FAIL !!
> ./practrand -gen=x -transform=exp | PractRand stdin64 -multithreaded
RNG_test using PractRand version 0.95
RNG = RNG_stdin64, seed = unknown
test set = core, folding = standard (64 bit)
rng=RNG_stdin64, seed=unknown
length= 256 megabytes (2^28 bytes), time= 3.0 seconds
Test Name Raw Processed Evaluation
BCFN(2+3,13-3,T) R= -8.3 p =1-9.6e-5 unusual
...and 212 test result(s) without anomalies
> ./practrand -gen=std -transform=exp | PractRand stdin64 -multithreaded
RNG_test using PractRand version 0.95
RNG = RNG_stdin64, seed = unknown
test set = core, folding = standard (64 bit)
rng=RNG_stdin64, seed=unknown
length= 256 megabytes (2^28 bytes), time= 3.0 seconds
no anomalies in 213 test result(s)
rng=RNG_stdin64, seed=unknown
gp@gp-thinkpad-x1 ~/d/_/s/build ((fee52b0d…))> ./SMHasher --test=Sanity,BadSeeds wyhash
--- Testing wyhash "wyhash v3 (64-bit)" GOOD
[[[ Sanity Tests ]]]
Verification value 0xA82DBAD7 ....... FAIL! (Expected 0x67031D43)
Running sanity check 1 .......... PASS
Running AppendedZeroesTest .......... PASS
[[[ BadSeeds Tests ]]]
> time ./birthday.wyrandskip65536.sort 10
Testing skipping_rng<WyRand,65536>
0..281474976710655 is range of generator
75029991 outputs to scan for duplicates [4.47214*sqrt(range)]
10 duplicates expected on average
4.54e-05 is probability of zero duplicates
0x54a2be72 is seed for this run
---
- Testing for repeats started...
- Allocating memory started...
> time ./birthday.spitmix64skip65536.sort 10
Testing skipping_rng<SplitMix64,65536>
0..281474976710655 is range of generator
75029991 outputs to scan for duplicates [4.47214*sqrt(range)]
10 duplicates expected on average
4.54e-05 is probability of zero duplicates
0x3b218eae is seed for this run
---
- Testing for repeats started...
- Allocating memory started...

All results are for GCE free tier: 4 2vCPU, 7.5GB machines; EU datacenter.

gp@manager:~$ uname -a
Linux manager 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) x86_64 GNU/Linux
gp@manager:~$ java -version
openjdk version "1.8.0_72-internal"
OpenJDK Runtime Environment (build 1.8.0_72-internal-b15)
package main
import (
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello\n"))
})
package main
import (
"flag"
"fmt"
"math/rand"
"runtime"
)
type (