digitalmars.D - Benchmarks and anonymous delegates
- Vadym Stetsiak (18/18) Nov 19 2009 Hi, all
- Andrei Alexandrescu (6/30) Nov 19 2009 This needs to be looked at. My guess is a bug in the compiler, but the
Hi, all I'm encountering strange behavior when using anonymous delegates with bechmark function. In my case benchmark hangs and consumes 100% CPU. I'm using D2. Here's the code: import std.date; void main() { ulong[] measures = benchmark!(delegate void() { for(int i = 0; i < 100_000; i++) { auto res1 = cmp1 == cmp2; } })(1, null); } OTOH, when instead of anonymous delegate i use predefined function, benchmarks works just fine. What I'm missing?
Nov 19 2009
Vadym Stetsiak wrote:Hi, all I'm encountering strange behavior when using anonymous delegates with bechmark function. In my case benchmark hangs and consumes 100% CPU. I'm using D2. Here's the code: import std.date; void main() { ulong[] measures = benchmark!(delegate void() { for(int i = 0; i < 100_000; i++) { auto res1 = cmp1 == cmp2; } })(1, null); } OTOH, when instead of anonymous delegate i use predefined function, benchmarks works just fine. What I'm missing?This needs to be looked at. My guess is a bug in the compiler, but the library may be at fault as well. Any chance you could please submit a bug report? http://d.puremagic.com/issues/enter_bug.cgi Andrei
Nov 19 2009