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

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

String Immutability

Google Cloud Professional Cloud Architect (PCA) certification — Best 2022 resources

Google Cloud Certified — Professional Cloud Architect badge

Why Python !?

Hostinger Web Hosting Review|A Good Choice For Beginners & Professionals

Upgrading A Dull Python Game Into A More Interactive Approach

From 12 to +50 tickets a month, lessons learnt

Tips to choose a Right Web Development Company for Your Next Project

Write your code with TDD !

TDD State Diagram

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
Fletch

Fletch

More from Medium

Conditional Statement (Control Statement)

The Why and How of Learning C

programmer writing code

The Road from Code to Executable

UDP Client-Server Implementation in C — Idiot Developer