Comparison: Benchmarking base64 random value output from Rust, C language, and shell script
Hello, it's me, the incompetent one.
GNU/Linux can generate random values from /dev/random, but how much difference is there when compared to Clang?
It goes without saying that Clang is faster! But let's take a look anyway.
Execution environment: ThinkPad X230

Sorry it's old.
time for i in {1…500}; do head -c 15 /dev/random | base64; done
~~~
lsWpWr1qsqAxqPCwkHLB
jw8gkw+m6H1sfeFoIL9t
5nGDUKmyFgley8vVcqll
sZ+rLscmCvMOH8EJHmrm
real 0m1.405s
user 0m1.344s
sys 0m0.556s
time for i in {1…500}; do ./random ; done
~~~
FyLg5Ad/ja2eqffx725k
wTXQ3Yuaqom7H7LpPjHB
KFX5xaDBj5s4yWDDHpnV
2e0nQA7IAdM9RiTO4tKV
real 0m0.424s
user 0m0.311s
sys 0m0.144s
Oh...
As expected from C.
And then Rust.
time for i in {1…500}; do ./rran ; done
~~~
bx6QlFg2vpc8RZywqwdD
kJRKlrCq7nZgGG9SBuqa
JKHpR14IAxiB/1cDF1QZ
z/4IujC1bbe9FteRRh2P
real 0m0.658s
user 0m0.435s
sys 0m0.256s
Oh...
Conclusion
C is the strongest, but considering learning and coding costs, Rust is easier.
Considering readability as a scripting language, I think shell scripts also have sufficient capability. Because,
**head -c 15 /dev/random | base64
**you can output it with just that...!?
Please excuse the rough comparison. Sorry.