Performance issue, disappearing with use of clock()

From: Berker, Yannick <Yannick.Berker_at_philips.com>
Date: Wed, 30 Nov 2011 12:53:21 +0000


Dear ROOT development team,

I recently came across a weird performance issue involving random number generation. If you take a look at the attached bug.cpp, you will see a minimum version of the code that I am using (not depending on any input data files). In this code, the inner loop runs incredibly slow (if it doesn't for you, just increase the upper limit from 1e6 to whatever takes long on your machine). You may say that generating a bunch of random numbers may well take some time, but what is striking is that once you uncomment the //clock(); line, the same loop runs lightning fast. To give you some numbers from my Windows machine:

with "//clock();"

1e4:   3.8 s
5e4:  17.5 s
1e5:  32.0 s
1e6: 343.7 s

with "clock();"

1e6: 0.6 s
5e6: 1.6 s
1e7: 3.1 s

I was able to reproduce this on several ROOT versions on several machines, including these: ROOT 5.26/00 (trunk_at_31882, Dec 14 2009, 20:18:36 on linuxx8664gcc) [Scientific Linux SL release 5.0] ROOT 5.32/00-rc2 (tags/v5-32-00-rc2_at_42055, Nov 16 2011, 13:47:39 on win32) [Windows 7 Enterprise SP 1]

In all cases, I executed the script using the command "root -q -b bug.cpp".

I would be glad about any advice or insight, because adding clock() in various places of my code may not always be sufficient to prevent such performance issues, and is certainly not good programming practice.

Best regards,
Yannick



The information contained in this message may be confidential and legally protected under applicable law. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, forwarding, dissemination, or reproduction of this message is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.

Received on Wed Nov 30 2011 - 13:54:38 CET

This archive was generated by hypermail 2.2.0 : Wed Nov 30 2011 - 17:50:01 CET