• Sokolov Yura's avatar
    runtime: implement fastrand in go · d03c1248
    Sokolov Yura authored
    So it could be inlined.
    
    Using bit-tricks it could be implemented without condition
    (improved trick version by Minux Ma).
    
    Simple benchmark shows it is faster on i386 and x86_64, though
    I don't know will it be faster on other architectures?
    
    benchmark                       old ns/op     new ns/op     delta
    BenchmarkFastrand-3             2.79          1.48          -46.95%
    BenchmarkFastrandHashiter-3     25.9          24.9          -3.86%
    
    Change-Id: Ie2eb6d0f598c0bb5fac7f6ad0f8b5e3eddaa361b
    Reviewed-on: https://go-review.googlesource.com/34782Reviewed-by: 's avatarMinux Ma <minux@golang.org>
    Run-TryBot: Minux Ma <minux@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    d03c1248
asm_386.s 38.6 KB