On Fri Oct 08 18:01:17 2010, ECARROLL wrote:
Show quoted text> nextgen doesn't load Moose into main, the main import is always
> 'mode' => ':procedural'.
I might not have been clear. nextgen.pm says "use Moose ();" which
means it always loads Moose. Whether it gets imported into main is
immaterial to this bug.
The patch is trivial and cuts nextgen.pm load time in half. Loading
mro, B::Hooks::EndOfScope and namespace::autoclean (that was the real
killer) on demand saves a further half.
diff --git a/lib/nextgen.pm b/lib/nextgen.pm
index b02154b..2feb3be 100644
--- a/lib/nextgen.pm
+++ b/lib/nextgen.pm
@@ -9,7 +9,6 @@ use v5.10.1;
## Core
use IO::Handle ();
-use mro ();
use feature ();
## CPAN procedural
@@ -17,10 +16,6 @@ use autodie ();
use indirect ();
## CPAN OO
-use Moose ();
-use B::Hooks::EndOfScope qw(on_scope_end);
-use namespace::autoclean ();
-
use nextgen::blacklist;
sub import {
@@ -49,14 +44,18 @@ sub import {
## Moose will import warnings and strict by default
if ( !$procedural && $pkg ne 'main' ) {
+ require mro;
mro::set_mro( $pkg, 'c3' );
-
+
+ require Moose;
Moose->import({ 'into' => $pkg })
unless $pkg->can('meta')
;
## Cleanup if the package has a new or meta (Moose::Roles)
- on_scope_end( sub {
+ require namespace::autoclean;
+ require B::Hooks::EndOfScope;
+ B::Hooks::EndOfScope::on_scope_end( sub {
no strict qw/refs/;
no warnings;
namespace::autoclean->import( -cleanee => $pkg )
Show quoted text> Any::Moose, and in fact Mouse and all things Mouse are hardly ever
> worth the trouble. They're actually quite slow.
The numbers say otherwise.
$ time perl -wle 'package Foo; use Moose'
real 0m0.231s
user 0m0.207s
sys 0m0.022s
$ time perl -wle 'package Foo; use Mouse'
real 0m0.039s
user 0m0.028s
sys 0m0.008s
(this is after making sure they're disk cached)
The 200ms cost of Moose is imposed on every use of nextgen.pm,
regardless of whether it wants to use Moose or not. You might argue
Mouse's runtime is slower (I'd be very surprised and would be interested
in the benchmarks) but that only matters if you actually use it.
Show quoted text> I don't think running perl in a non-persistent fashion is ever
> good idea. With that said, I'm inclined to reject this bug.
...so no command line programs using nextgen?