Benchmarking random float functions.

The classic rand() 15-bit range
A slower but higher entropy random with 23-bit range
Source 23-bit range
Source 23-bit range
Source1 Source2 15-bit range
Compiler Flags: none
rand_float1() Cycles: 24
rand_float2() Cycles: 4,740
rand_float3() Cycles: 37
rand_float4() Cycles: 36
rand_float5() Cycles: 18
Compiler Flags: -Ofast
rand_float1() Cycles: 23
rand_float2() Cycles: 4,762
rand_float3() Cycles: 34
rand_float4() Cycles: 31
rand_float5() Cycles: 17
---- with regular FPU sqrt
Compiler Flags: none
rand_normal_float1() Cycles: 80
rand_normal_float2() Cycles: 11,829
rand_normal_float3() Cycles: 121
rand_normal_float4() Cycles: 121
rand_normal_float5() Cycles: 94
Compiler Flags: -Ofast
rand_normal_float1() Cycles: 75
rand_normal_float2() Cycles: 11,951
rand_normal_float3() Cycles: 117
rand_normal_float4() Cycles: 110
rand_normal_float5() Cycles: 52
---- with intrinsic sqrtps
Compiler Flags: none
rand_normal_float1_sqrtps() Cycles: 82
rand_normal_float2_sqrtps() Cycles: 11,936
rand_normal_float3_sqrtps() Cycles: 128
rand_normal_float4_sqrtps() Cycles: 125
rand_normal_float5_sqrtps() Cycles: 97
Compiler Flags: -Ofast
rand_normal_float1_sqrtps() Cycles: 69
rand_normal_float2_sqrtps() Cycles: 11,934
rand_normal_float3_sqrtps() Cycles: 116
rand_normal_float4_sqrtps() Cycles: 112
rand_normal_float5_sqrtps() Cycles: 53
Box-Muller transformation

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store