From: Stevan Little Date: Wed, 11 Oct 2006 15:04:37 +0000 (+0000) Subject: some more benchmarks X-Git-Tag: 0_15~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7623f7745394bab6122a18b42da2d35897510f2f;p=gitmo%2FMoose.git some more benchmarks --- diff --git a/Changes b/Changes index a79f3ea..60118f5 100644 --- a/Changes +++ b/Changes @@ -8,8 +8,8 @@ Revision history for Perl extension Moose * Moose::Meta::Attribute - changed how we do type checks so that - we reduce the overall cost by approx. - factor of 5 + we reduce the overall cost, but still + retain correctness. * Moose::Meta::TypeConstraint - changed how constraints are compiled diff --git a/benchmarks/simple_class.pl b/benchmarks/simple_class.pl new file mode 100644 index 0000000..bb8aef1 --- /dev/null +++ b/benchmarks/simple_class.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Benchmark::Forking qw[cmpthese]; + +=pod + +This compares the burden of a basic Moose +class to a basic Class::MOP class. + +It is worth noting that the basic Moose +class will also create a type constraint +as well as export many subs, so this comparison +is really not fair :) + +=cut + +cmpthese(5_000, + { + 'w/out_moose' => sub { + eval 'package Bar; use metaclass;'; + }, + 'w_moose' => sub { + eval 'package Baz; use Moose;'; + }, + } +); + +1; \ No newline at end of file diff --git a/benchmarks/simple_compile.pl b/benchmarks/simple_compile.pl new file mode 100644 index 0000000..f12c518 --- /dev/null +++ b/benchmarks/simple_compile.pl @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Benchmark::Forking qw[cmpthese]; + +=pod + +This compare the overhead of Class::MOP +to the overhead of Moose. + +The goal here is to see how much more +startup cost Moose adds to Class::MOP. + +NOTE: +This benchmark may not be all that +relevant really, but it's helpful to +see maybe. + +=cut + +cmpthese(5_000, + { + 'w/out_moose' => sub { + eval 'use Class::MOP;'; + }, + 'w_moose' => sub { + eval 'use Moose;'; + }, + } +); + +1; \ No newline at end of file diff --git a/benchmarks/type_constraints.pl b/benchmarks/type_constraints.pl index 7b1469b..dcc15cd 100644 --- a/benchmarks/type_constraints.pl +++ b/benchmarks/type_constraints.pl @@ -5,6 +5,14 @@ use warnings; use Benchmark qw[cmpthese]; +=pod + +This benchmark compares the overhead of a +auto-created type constraint vs. none at +all vs. a custom-created type. + +=cut + { package Foo; use Moose;