Strange Problem About A False Loop

Hi, ROOTers.

I found it took me really long time to run following codes in ROOT, and it is really confusing.

void test()
{
Int_t i, j;

for(i = 0; i < 1000000; i++)
{
  for(j = 0; j < 0; j++) {}
}

}

However, such code runs much more quickly.

void test()
{
Int_t i, j;

for(i = 0; i < 1000000; i++)
{
  for(j = 0; j < 1; j++) {}
}

}

I have tested this problem in v5.14 and v5.17, and in both version the problem occured. I’m wondering if it is a bug of Cint, or what else.

Thanks a lot in advance for any help.

On my Linux box with version 5.17/04, your top code runs in 0.63 seconds and
the bottom code in 0.89 seconds. This looks correct. What are your values and conditions?

Rene

[quote=“brun”]On my Linux box with version 5.17/04, your top code runs in 0.63 seconds and
the bottom code in 0.89 seconds. This looks correct. What are your values and conditions?

Rene[/quote]

Hi, thank you for reply. But on my computer, with SLC4.13 and ROOT v5.17, the top code takes 36.428s while the bottom one only takes 0.767s. The time difference is quite large and I don’t know why.

Could you tell us:
-which version of gcc?
-which ROOT version ? 5.17/02, 5.17/04, other?
-Did you install from source yourself? if not from which binary?

Rene

[quote=“brun”]Could you tell us:
-which version of gcc?
-which ROOT version ? 5.17/02, 5.17/04, other?
-Did you install from source yourself? if not from which binary?

Rene[/quote]

Sure.
1.My gcc version is 3.4.6.
2.My ROOT version is 5.17/02. I have asked my colleagues to help to test, and it turns out that the problem also occurs under v5.14 and v5.16.
3.I compiled my ROOT from source.

Hi,

Could please try 5.17/04? There was a small change in the byte code compiler that improved the performance of some nested loops.

Cheers,
Philippe.

[quote=“pcanal”]Hi,

Could please try 5.17/04? There was a small change in the byte code compiler that improved the performance of some nested loops.

Cheers,
Philippe.[/quote]

Hi,

I switched to 5.17/05 today, and the problem disappeared. Thanks a lot to all of you for your effort and help.

Cheers,
liuk