in reply to Which is the best compiler

As Corion pointed out, Perl is an interpreted language. When you run a Perl script, it goes through a "compilation" stage, but that only takes it to a stage that is easier for the interpreter to deal with. And all this is contained within the single perl executable. There are much more recent versions of Perl available. ActiveState currently is dispensing version 5.8.6.

If your problem is startup time, you could convert your script to something that is "always on", just waiting (blocking) for input. Or if we're talking about CGI, you could switch over to mod_perl, which eliminates the startup cost of your script.

If your problem is runtime speed, profile to find the bottlenecks, and then rework the key segments of code that are slowing you down. You may find that the script is IO bound rather than CPU bound. Or you may find that there's a really poorly written algorithm somewhere that is taking O(n^2) (or worse) time. If you can rework a key algorithm from O(n^2) time to O(n log n), you gain a magnitude of better time efficiency. Convert O(n log n) to O(n), to O(log n), to O(1), and each time you realize a dramatic improvement in runtime speed. Maybe there's a situation where you should be using a hash instead of grepping a list, etc. But definately profile before optimizing so you'll know where to focus your efforts, and which small fish to let go.


Dave

Replies are listed 'Best First'.
Re^2: Which is the best compiler
by agynr (Acolyte) on Jan 18, 2005 at 10:57 UTC
    The problem is not the execution time but the problem is that it is taking 50% of CPU for each and every program it runs, irrespective of the code for which it is running. I am not able to any application say any other execution of perl file for example. I have also tried with the Active Perl 5.8(Latest Version) but the problem remains the same. Please suggest me what should I pursue for.
      50% of CPU doesn't say anything at all. If only 50% of the CPU is used, you're underusing the system. Remember that the fraction of CPU time gets allocated to a process is a task of your kernels scheduler, and the sceduler takes into account a lot of variables to decide how much time a process gets. And each OS has its own scheduler - which some OSses, there's even the possibility to tune it. A not complete list of things taken into account:
      • How many processes there are in the run queue.
      • How many processors there are available to the OS.
      • The process' priority.
      • How long the process has been running.
      • How long the process has been waiting for a time slot.
      • If the process is doing a page fault, is it a minor or a major fault?
      • Interrupts.
      • Blocking system calls.
      • ...