Re: [Boston.pm] Junction performance
> "JP" == Jerrad Pierce <[EMAIL PROTECTED]> writes: JP> Exactly, but being greased lightning I didn't feel it was necessary to JP> substitute teflon for grease :-P speed and benchmarking aside, i felt it was better and easier to read code. :) and i was also writing for the list about accurate benchmarking. i have seen too many that report some result but it was skewed by poor understanding of how to write a benchmark that isolates the code you are testing. JP> Your code reports: JP> ANY: JP> s/iterQSP6 JP> QS 1.20-- -98% JP> P6 2.10e-002 5611%-- JP> ALL: JP> RateQSP6 JP> QS 1.46/s-- -98% JP> P6 79.2/s 5337%-- and yours had: JP> ANY: JP> s/iterQSP6 JP> QS 1.22-- -98% JP> P6 2.04e-002 5889%-- JP> ALL: JP> RateQSP6 JP> QS 1.44/s-- -98% JP> P6 78.0/s 5318%-- so it seems that my version is more accurate with ANY and they are about the same with ALL. hmmm. in this case, the module speed differences are so great, that factoring out the common overhead code didn't gain much percentagewise. uri -- Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs http://jobs.perl.org ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
Re: [Boston.pm] Junction performance
Exactly, but being greased lightning I didn't feel it was necessary to substitute teflon for grease :-P Your code reports: ANY: s/iterQSP6 QS 1.20-- -98% P6 2.10e-002 5611%-- ALL: RateQSP6 QS 1.46/s-- -98% P6 79.2/s 5337%-- -- H4sICNoBwDoAA3NpZwA9jbsNwDAIRHumuC4NklvXTOD0KSJEnwU8fHz4Q8M9i3sGzkS7BBrm OkCTwsycb4S3DloZuMIYeXpLFqw5LaMhXC2ymhreVXNWMw9YGuAYdfmAbwomoPSyFJuFn2x8 Opr8bBBidcc= -- MOTD on Setting Orange, the 8th of The Aftermath, in the YOLD 3171: J'en fais peu mais je le fais bien ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
Re: [Boston.pm] Junction performance
> "JP" == Jerrad Pierce <[EMAIL PROTECTED]> writes: JP> In case anyone is interested: JP> ANY: JP> s/iterQSP6 JP> QS 1.22-- -98% JP> P6 2.04e-002 5889%-- JP> ALL: JP> RateQSP6 JP> QS 1.44/s-- -98% JP> P6 78.0/s 5318%-- quite a speedup. you can make the benchmark more accurate by factoring out some of the work you are doing in each call. JP> package main; JP> use Benchmark; JP> sub ANY{ JP> if( &{$_[0].'::any'}(1 .. 10_000) > 10_001 ){ JP> warn "This should not happen\n"; JP> } JP> if( &{$_[0].'::any'}(1 .. 10_000) == 42 ){ JP> #print "The Answer\n"; JP> } JP> } JP> sub ALL{ JP> unless( &{$_[0].'::all'}(1 .. 10_000) < 10_001 ){ JP> warn "This should not happen\n"; JP> } JP> } declare my @int = 1 .. 10_000 outside the subs and remove that building of the list each time. also you are doing symrefs which are slow. you can easily change this to use code refs. my @ints = ( 1 .. 10_000 ) ; sub ALL{ unless( $_[0]->( @ints ) < 10_001 ){ warn "This should not happen\n"; } } sub ANY{ if( $_[0]->( @ints ) > 10_001 ){ warn "This should not happen\n"; } if( $_[0]->( @ints ) == 42 ){ #print "The Answer\n"; } } Benchmark::cmpthese(50, { P6=>sub{ ANY \&Perl6::Junction::any }, QS=>sub{ ANY \&Quantum::Superpositions::any } }); Benchmark::cmpthese(50, { P6=>sub{ ALL \&Perl6::Junction::all }, QS=>sub{ ALL \&Quantum::Superpositions::all } }); i don't have those installed but i would be curious as the new numbers as the changes will emphasize the any/all code more this way. and also try a range of list sizes. some algorithms work better with different sized inputs. you could automate that with a array of int lists and them also passing in a ref to one of those in the benchmark calls. then just loop over the int lists and you can get a table of results with multiple input sizes. uri -- Uri Guttman -- [EMAIL PROTECTED] http://www.stemsystems.com --Perl Consulting, Stem Development, Systems Architecture, Design and Coding- Search or Offer Perl Jobs http://jobs.perl.org ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm
[Boston.pm] Junction performance
In case anyone is interested: ANY: s/iterQSP6 QS 1.22-- -98% P6 2.04e-002 5889%-- ALL: RateQSP6 QS 1.44/s-- -98% P6 78.0/s 5318%-- __CODE__ package Bob; use Perl6::Junction; use Quantum::Superpositions; package main; use Benchmark; sub ANY{ if( &{$_[0].'::any'}(1 .. 10_000) > 10_001 ){ warn "This should not happen\n"; } if( &{$_[0].'::any'}(1 .. 10_000) == 42 ){ #print "The Answer\n"; } } sub ALL{ unless( &{$_[0].'::all'}(1 .. 10_000) < 10_001 ){ warn "This should not happen\n"; } } print "ANY:\n"; Benchmark::cmpthese(50, { P6=>sub{ANY 'Perl6::Junction'}, QS=>sub{ANY 'Quantum::Superpositions'} }); print "ALL:\n"; Benchmark::cmpthese(50, { P6=>sub{ALL 'Perl6::Junction'}, QS=>sub{ALL 'Quantum::Superpositions'} }); -- H4sICNoBwDoAA3NpZwA9jbsNwDAIRHumuC4NklvXTOD0KSJEnwU8fHz4Q8M9i3sGzkS7BBrm OkCTwsycb4S3DloZuMIYeXpLFqw5LaMhXC2ymhreVXNWMw9YGuAYdfmAbwomoPSyFJuFn2x8 Opr8bBBidcc= -- MOTD on Setting Orange, the 8th of The Aftermath, in the YOLD 3171: J'en fais peu mais je le fais bien ___ Boston-pm mailing list Boston-pm@mail.pm.org http://mail.pm.org/mailman/listinfo/boston-pm