P is for Practical | |
PerlMonks |
Re^7: Rosetta Code: Long List is Long (Updated Solutions - short Perl GRT and for_list)by eyepopslikeamosquito (Archbishop) |
on Jan 02, 2023 at 09:58 UTC ( [id://11149284]=note: print w/replies, xml ) | Need Help?? |
llil2cmd.pl - abbreviated version of llil2grt.pl For cheap thrills, I created llil2cmd.pl, a short command line version of llil2grt.pl:
Curiously, this abbreviated version runs at about the same speed on Windows, but significantly faster on my Ubuntu Linux VM:
To get more detailed timings, I hacked out a long short version:
As you can see from the times reported by the Linux time command, it seems that large lexical variables in Perl are significantly slower to cleanup at program exit than non-lexicals (about three seconds slower in this example: 33.475s vs 30 secs for llil2grt.pl, 28.629s vs 28 secs for llil2cmd-long.pl). New perl 5.36 experimental for_list feature After stumbling upon perl 5.36 and the for_list feature - a simple speed comparison I had to give the perl 5.36 for_list feature a try (update: List::Util's pairmap might be worth a try given it was mentioned in a reply). After building perl v5.36 from source (my Ubuntu system perl is v5.34 - update see improved build perl 5.38 notes): and adding: to the top of llil2grt.pl while changing one line from: to: it produced the same result, but did not run appreciably faster. Update: as for why it isn't much faster, see ikegami's replies at: Re^2: Why does each() always re-evaluate its argument? (Updated x2 - experimental "for_list" ) Update: Improved Ubuntu Perl Build Notes
Manual install of CPAN Roman module Later I manually installed Roman by CHORNY from CPAN into this local non-root Perl 5.36 as follows:
Update: Better to do it via: cpanm --from https://www.cpan.org/ --verify Roman 2>&1 | tee Roman.tmp Updated: Added steps for building perl v5.36.0 from source and manual install of Roman module. Noted that large lexical variables are slower to cleanup at program exit.
In Section
Meditations
|
|