hanabi1224 / hanabi1224/Programming-Language-Benchmarks
request: add loop benchmark
- Dominant language
- C#
- Stars
- 800
- Forks
- 167
- PR merge metrics
- No merged PRs in 30d
Description
sometime we don't need complicated algorithm to see performance of programming
language, we just need to see how these language loop's implemetation, all benchmark
game like binarytree, fasta, etc just only test loop implementation of language and sometime
benchmark implementation syscall like 'print' to console through loop
example just loop for 1000_000_000 (billion) in linux bash for various language,
i'm using digitalocean cloud with centos7
perl 5.16 -> 5 secs just loop
# time perl -e 'my $a = 1; for $i (0 .. 1000000000){$a+=4}; print $a'
4000000005
real 0m5.020s
user 0m5.006s
sys 0m0.009s
-
--- php 5.4.16 -> 3.5 secs just loop
# time php -r '$a = 1; for($i=0;$i<=1000000000;$i++){ $a+=4; } echo $a;'
4000000005
real 0m3.536s
user 0m3.502s
sys 0m0.032s
--- php 8.2.8 -> 1.2 secs just loop
# time php82 -r '$a = 1; for($i=0;$i<=1000000000;$i++){ $a+=4; } echo $a;'
4000000005
real 0m1.181s
user 0m1.152s
sys 0m0.029s
-
python
--- src
# cat loop.py
a = 1
for i in range(0,1000000001):
a += 4
print(a)
--- python2 -> error just loop
# time python loop.py
Traceback (most recent call last):
File "loop.py", line 2, in
for i in range(0,1000000000):
MemoryError
--- python3 -> 30 secs just loop
# time python3 loop.py
4000000005
real 0m30.887s
user 0m30.857s
sys 0m0.015s
-
C gcc 11.2.1
--- src
# cat loop.c
#include
void main(){
long i,a=1;
for(i=0;i<=1000000000;i++){
a += 4 ;
}
printf("%lli",a);
}
--- default optimation -> 0.5 secs just loop
# gcc -o loop loop.c
# time loop
4000000005
real 0m0.526s
user 0m0.523s
sys 0m0.003s
--- O3 optimation -> 0.002 secs just loop
# gcc -O3 -o loop loop.c
# time loop
4000000005
real 0m0.003s
user 0m0.001s
sys 0m0.002s
note:
we need simple operation on loop like a+=4 so the optimizer of language 'dont cheat' the output, because empty operation might make some language optimizer skip loop operation
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.