Re: Fast of program
Levi Elias Nystad-Johansen via beginners <[email protected]> Mon, 16 Oct 2023 17:40:08 +0000
| Newsgroups | gmane.comp.lang.perl.beginners |
|---|---|
| Message-ID | <tDGvF7t0nCwzqklrxs14AF_Xz-0L37frhPlQJ_mRnXEGvwF7_l2TPQLH9LC0xiJCJ-rm50nWLEXuZ_XxgfMWr6Xj6uvVFPX2FA__Vkl0034=@protonmail.com> |
Before optimizing, it is recommended to run a profiler to see where the code is spending the most time. Here is a good perl profiler: https://metacpan.org/pod/Devel::NYTProf There are many tricks to make code faster, here are some that I often use: - caching results of slow calculations - keeping track of states with bit manipulation (like enums) - using alias/references to avoid copying variables when not needed Here is a video of various small tricks in perl to make code run faster: https://www.youtube.com/watch?v=jV5Zv3zc3o8 It is difficult to advise without seeing the code, you could post the code to https://perlmonks.org/ to get some good feedback :) -L ------- Original Message ------- On Monday, October 16th, 2023 at 4:41 PM, William Torrez Corea <[email protected]> wrote: > How can I make a program faster? > > Perl is the fastest, taking 1.9s. Ruby is the second fast, taking 3.0s. Scala script is the slowest, taking 4.0s. > > Maybe I can use a algorithm but what? > > -- > > With kindest regards, William. > > ⢀⣴⠾⠻⢶⣦⠀ > ⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system > ⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org > ⠈⠳⣄⠀⠀⠀⠀