in reply to Question about benchmarking
Thanks for the compliment, this is my first "big" perl project :). The code is still at work (I forgot to bring it home), but I'll remember to get it tomarrow and post it.
Just a few questions:
That seems way too simple too work, I don't trust it. Also, do you think that Benchmark or Time::HiRes slow my program down significantly?use Benchmark; $start=new Benchmark; run_around_in_circle(1000); $end=new Benchmark; print timestr(timediff($end, $start));
Thanks again.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Question about benchmarking
by toma (Vicar) on Aug 17, 2001 at 07:59 UTC | |
One difficult part of benchmarking is keeping track of what you have changed, and what effect these changes had. Here is one way to do it: First, isolate the part of your code that needs improvement in a subroutine. Then, create new subroutines with different names to try different approaches. Preserve the different implementations of the subroutine in the program. This ensures that you don't accidentally change something else in your code that ruins your comparison data. The Benchmark node mentioned above shows an example of this approach. If you keep your subroutine short, it is easy for other people, such as Perl Monks, to help speed up your code. It should work perfectly the first time! - toma | [reply] |
|
Re: Re: Question about benchmarking
by Anonymous Monk on Aug 17, 2001 at 04:38 UTC | |
to read the POD for the module. If you have a somewhat old and/or broken install (like me), you can always fall back to :) What you've written is a proper way of using benchmark. Ideally, you would insert several objects into your code to get the times you wanted, but you can do it in a clever and inobtrusive manner: and then it would be trivial to remove the benchmarking from your production code, either through a command line switch, as above: or some line in your makefile like: ya know. | [reply] [d/l] [select] |
|
Re: Re: Question about benchmarking
by perrin (Chancellor) on Aug 17, 2001 at 06:07 UTC | |
| [reply] |
|
Re: Re: Question about benchmarking
by lestrrat (Deacon) on Aug 17, 2001 at 05:12 UTC | |
You don't trust it because it's simple?! Well, I guess you still don't have that much experience, but here's a universal truth: the best code is usually the most simple. Usually. Anyways, I don't know exactly how your program works, but I would first suggest to use you friend, Devel::Dprof. ( I'm not sure what you didn't understand about the output from Devel::Dprof, but it's pretty straight forward, I think.... It's just shows in order which subroutines were accessed most frequently ) | [reply] |
|
Re: Re: Question about benchmarking
by jryan (Vicar) on Aug 18, 2001 at 00:27 UTC | |
Thanks for that information about benchmarking, that is exactly what I needed. Btw, what I meant by "I don't trust it because it is too simple" is that it looked like too simple of a solution to what looked to be a complex problem, but really wasn't. For those who still want to see the code, here it is (I've removed all of the stuff that doesn't have to do with the hierarchy part, to cut down on confusion):
I'm sure I can scope a lot of these variables a little better, and I'm sure that their are some more efficient ways to do some of the things I was doing (via a built-in function, etc.). If anyone sees anything at all to help sprouse it up, by all means tell me! | [reply] [d/l] |