Le Wed, 03 Jun 2009 02:40:11 +0200, Diwaker Gupta
<diwa...@floatingsun.net> a écrit:
I've just started to play around with D, and I'm hoping someone can
clarify this. I wrote a very simple program that just allocates lots of
objects, in order to benchmark the garbage collector in D. For
comparison, I wrote the programs in C++, Java and D:
C++: http://gist.github.com/122708
Java: http://gist.github.com/122709
D: http://gist.github.com/121790
With an iteration count of 99999999, I get the following numbers:
JAVA:
0:01.60 elapsed, 1.25 user, 0.28 system
C++:
0:04.99 elapsed, 4.97 user, 0.00 system
D:
0:25.28 elapsed, 25.22 user, 0.00 system
I think the line 14 in the D source is useless.
On my linux system :
D with line 14 removed :
----------------------
ts...@fgabriel:~/dev/DBenchmark$ time ./Benchmark allocations 99999999
787459713
real 0m28.779s
user 0m28.778s
sys 0m0.004s
C++:
---
ts...@fgabriel:~/dev/DBenchmark$ time ./a.out allocations 99999999
Ran 99999999 allocations of RunAllocations. Final value: 787459713
real 0m16.406s
user 0m16.405s
sys 0m0.004s
Java :
-----
ts...@fgabriel:~/dev/DBenchmark$ time java Benchmark allocations 99999999
Ran 99999999 allocations of RunAllocations. Final value: 787459713
real 0m6.679s
user 0m6.408s
sys 0m0.248s
But with the use of "scope" keyword at line 13 of the D source :
ts...@fgabriel:~/dev/DBenchmark$ time ./Benchmark allocations 99999999
787459713
real 0m10.752s
user 0m10.753s
sys 0m0.000s