www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Benchmarks and anonymous delegates

reply Vadym Stetsiak <vadmyst gmail.com> writes:
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
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
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