-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 If you're writing a runnable script in Perl 6, I would recommend to *always* use a MAIN sub[1]. If you're using that, you can easily achieve the precompilation as well, with 1 line of code less.
You'd have your code in lib/Your/Program/Main.pm6: sub MAIN ( # You can let Perl 6 handle arguments here ) is export { # Program code here } Next, the script that you actually run would be in bin/program, and contain the following code: use lib "./"; use Your::Program::Main; This should give you all of the Perl 6 MAIN goodness, and a faster program. [1]: https://docs.perl6.org/language/functions#index-entry-MAIN On Mon, 6 Aug 2018 10:56:43 +0100 Simon Proctor <simon.proc...@gmail.com> wrote: > So Perl6 is a lot like Python in that modules get compiled to byte > code making them a lot faster to parse the second time around. > > If you're running a 6000 line script then a lot of time is going to be > spent parsing your script every time you run it. If you instead take > all your script code and pop it into a module and have a script along > the lines of : > > use lib "./"; > use System; > > System::start(); > > (Where your module code is called System.pm6 and start is the entry > point subroutine). > > I think you'd find this improves the speed of the script > significantly. > > On Mon, 6 Aug 2018 at 10:38 ToddAndMargo <toddandma...@zoho.com> > wrote: > > > On 08/06/2018 02:07 AM, ToddAndMargo wrote: > > > On 08/06/2018 01:02 AM, Simon Proctor wrote: > > >> Sorry I wrote my earlier email on my phone without a computer to > > >> hand. Here's a quick rundown on what I'm talking about. > > >> > > >> --stagestats gives you the breakdown on how much time is spent > > >> doing various steps (note that using time instead of date; date > > >> gives you a better timing of how long something took. > > >> > > >> time perl6 --stagestats -e "" > > >> Stage start : 0.000 > > >> Stage parse : 0.089 > > >> Stage syntaxcheck: 0.000 > > >> Stage ast : 0.000 > > >> Stage optimize : 0.001 > > >> Stage mast : 0.004 > > >> Stage mbc : 0.000 > > >> Stage moar : 0.000 > > >> > > >> real 0m0.144s > > >> user 0m0.155s > > >> sys 0m0.032s > > >> > > >> And generally that's going to be the case for most short > > >> programs, in these cases especially moving to having the core of > > >> your code in modules with give you a speed boost. > > >> > > >> Sorry if my comments earlier were unhelpful. > > >> > > >> Simon > > >> > > >> On Mon, 6 Aug 2018 at 08:56 ToddAndMargo <toddandma...@zoho.com > > >> <mailto:toddandma...@zoho.com>> wrote: > > >> > > >> >> On Sun, 5 Aug 2018, 23:45 Elizabeth Mattijsen, > > >> >> <l...@wenzperl.nl > > >> <mailto:l...@wenzperl.nl> > > >> >> <mailto:l...@wenzperl.nl <mailto:l...@wenzperl.nl>>> wrote: > > >> >> > > >> >> > On 1 Aug 2018, at 20:14, ToddAndMargo > > >> <toddandma...@zoho.com <mailto:toddandma...@zoho.com> > > >> >> <mailto:toddandma...@zoho.com > > >> <mailto:toddandma...@zoho.com>>> wrote: > > >> >> > Is it just me or does Perl 6 take about three > > >> >> > times as > > >> long to > > >> >> > start up as Perl 5? I do have a very fast > > >> >> > machine and it > > >> takes > > >> >> > about seven see for some of my Perl 6 stuff to > > >> >> > get past > > >> the > > >> >> > ruminating phase and start running. > > >> >> > > >> >> Seven seconds? Seven? That seems *very* long > > >> >> indeed. > > >> >> > > >> >> How long does it take to do: > > >> >> > > >> >> perl6 -e ‘’ > > >> >> > > >> >> ? That should be in the order of 130 msecs. If > > >> >> that’s the > > >> case, > > >> >> then you’re probably doing a lot of grammar changes > > >> >> to Perl > > >> 6. But > > >> >> without the actual code, this remains guessing. > > >> >> > > >> >> > > >> >> > Any workaround for this, or is this just growing > > >> >> > pains > > >> for Perl 6? > > >> >> > > >> >> Not sure :-) > > >> >> > > >> >> > > >> >> > > >> >> Liz > > >> >> > > >> >> -- > > >> >> Simon Proctor > > >> >> Cognoscite aliquid novum cotidie > > >> > > >> On 08/05/2018 10:57 PM, Simon Proctor wrote: > > >> > Have you tried running with --stagestats which gives you > > >> > a break > > >> down of > > >> > where the time is being spent? > > >> > > > >> > On thing is if you are running large script files it came > > >> > take a > > >> while. > > >> > Moving your code into modules, which get precompiled can > > >> > give a significant speed boost. > > >> > > >> Does this tell you anything? > > >> > > >> $ curl --fail --head https://google.com; echo $? > > >> HTTP/2 301 > > >> location: https://www.google.com/ > > >> content-type: text/html; charset=UTF-8 > > >> date: Mon, 06 Aug 2018 05:19:51 GMT > > >> expires: Wed, 05 Sep 2018 05:19:51 GMT > > >> cache-control: public, max-age=2592000 > > >> server: gws > > >> content-length: 220 > > >> x-xss-protection: 1; mode=block > > >> x-frame-options: SAMEORIGIN > > >> alt-svc: quic=":443"; ma=2592000; v="44,43,39,35" > > >> > > >> 0 > > >> > > >> -- > > >> Simon Proctor > > >> Cognoscite aliquid novum cotidie > > > > > > real 0m14.580s > > > user 0m13.723s > > > sys 0m0.418s > > > > > > The program is 6160 line long plus a bunch of imported > > modules. > > > > The Perl 5 version of this program that starts three > > times faster is 6354 lines long plus a bunch if imported > > modules. > > > > The slow start is not a reason to go back to p5 for > > any reason. It would just be nice if it started faster. > > -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE4eL662U9iK2ST2MqN/W6H45XOE8FAltoHxYACgkQN/W6H45X OE+CKwf7B5Qqm90qg9ofY6SFiDQEbE3lBPBOn8QsXnkjSF6/sgIhXLuDESa//2oe na2nguEldNViEXg33rx99XUhkCkFTDEpYiMGBnjseeFQ9m5Z4qum0YmnMyatBkL7 fg+WedSKJEPP2IuRRD8AXQIoO9vPvtGZy14lEaDfoFkwK2r1QhH4+0lyBZOnw/TX 5rNHTCBcyEgqEgDzb0pOXsIDcgHLtM/oSPb4OQ7k5YA8wPE1QMVS+3CTtTXlMOVg uUi/uVHMws8XLn5thNfuAvSqriYXoQJONLvkAUnl36P+z1bzz5pwB5qJtPHeLFf4 KKhAzf5twrGuY30rx82bG1da/xBrlg== =UG3r -----END PGP SIGNATURE-----