in reply to use less 'CPU'

There is a big chance that, when "use less" is finally implemented, might be in Perl 6, it will be called "use optimize", which makes more sense.

This example:
"use less CPU => 40, memory => '30M';"

does not fit very well with the original purpose of having "use less" or "use optimize".

The root purpose of "use optimize" or "use less" is to allow Perl to make speed/memory trade off at either run time or compile time (details would be determined by the implementation). If you say "use optimize CPU", Perl would try to use more memory if that speeds up your script; or the other way around, if you specify "use optimize memory". (Be aware that, up till now, Perl usually trade memory for speed)

To specify the number amount is "a little bit" less meaningful in the real world ;-). For example, what does "use less memory => 30M" really mean? if your program is deemed to use 35M, what should Perl do? Especially if you specify both less memory and less CPU, (with or without number amount attached), Perl would be put into a dilemma, and does not know what to do.

Replies are listed 'Best First'.
Re: Re: use less 'CPU'
by powerman (Friar) on Feb 14, 2003 at 23:23 UTC
    Yeah, you right. Thanks for explanation!

    About memory limit... to be fair enough, I just copy this word from `perldoc less` and add parameter for fun - I don't mean something special here. But ability to limit memory sometimes very good idea. I don't mean perl optimizations here or OS limits like `setrlimit` (because as far as I know it's impossible to handle these limits - OS just kill the process).

    All you know what perl eat a lot of memory - it trade memory for speed. But user's script sometimes also trade memory for speed. All sort of caches do this. And I think it's a good to know inside script what it reach some memory limits. In this case user can set callback routine or signal handler which will empty caches, flush buffers, etc.