in reply to Subroutine speed
Well I am a bit puzzled about the subroutine calls eating the processor.Well, it's known that sub calls are somewhat expensive in perl. But does it really matter? In most cases I find it doesn't. If you're really concerned about this you could try benchmarking (Benchmark).
Update: I've tried to link to Benchmark.pm's online documentation by means of [doc://Benchmark], but it links to http://www.perldoc.com/perl5.8.0/pod/func/Benchmark.html instead, which is not correct, of course. So I've inserted the link manually, but I'd like to know if I'm just being dense or if it should work as described in 43037.
All i want to check is about my code which uses a particlar set of lines which gets reapeated in 3 different places.In some cases an alternative to a sub is a loop, but you can't really do that if the three different places are too... ehm... different.
Update: I forgot mentioning that prototyped subs which accept no arguments introduce only a negligible overhead, which is why they're used for constant emulation. I want to stress, however, that this is not meant to be an invitation to share global variables instead of parameter passing, especially for the OP.
As my requirement is something like it takes 10-15 mins for the entire program to finish the task ,If i put those lines which get repeated into a subroutine take more time or leave it as it is.I doubt that this is a well-formed English sentence, but I'm not a native English speaker either...
If I understand you correctly, however, why don't you try yourself, perhaps as suggested above?
Btw I want some info about my previous doubt which involves entering formulas into a csv file through perl without using modules.As a matter of style I'd post such a different question in a different article. FWIW it doesn't make much sense to me: we should first agree on just what a "formula" is in a csv file.
As a side note evidence is that whenever someone ask about doing something "without modules" he's asking the wrong question for he's typically convinced that e.g. he can't install them locally, which often is not really the case.
Said this, csv files should be more or less manageable with "pure perl". We still have to understand that "formula thing".
Again I have a doubt wether using more modules will add to the processor hammering.Oh, so it's this that you're all concerned about!! Well: ditto as above i.e. why don't you try for yourself?
In any case as a general rule I'd answer negatively: chances are that you'll speed the whole thing up, especially if we're talking about XS modules - it's one of the reasons they're created in the first place!
|
|---|