Re: Fast of program
Levi Elias Nystad-Johansen via beginners <[email protected]> Tue, 17 Oct 2023 04:33:00 +0000
| Newsgroups | gmane.comp.lang.perl.beginners |
|---|---|
| Message-ID | <co1VfZVt9LOrHFLjz2hAMRm47AHdlUcjBRg3wMa8owWwJjz2kwOPe7vJl8ZALPdCc9dPPcQ6tCRsJrApSQSlQv0WhAxo0-yD-r4mEV3vUG0=@protonmail.com> |
Of course! 👍 -L -------- Original Message -------- On 16. okt. 2023, 22:03, Andy Bach wrote: > Keeping in mind Knuth's axiom: > "Premature optimization is the root of all evil" > https://wiki.c2.com/?PrematureOptimization > > On Mon, Oct 16, 2023 at 12:40 PM Levi Elias Nystad-Johansen via beginners <[email protected]> wrote: > >> 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 >>> ⠈⠳⣄⠀⠀⠀⠀ > > -- > > a > > Andy Bach, > [email protected] > 608 658-1890 cell > 608 261-5738 wk