Add a benchmark for new_object()
Fuji, Goro [Sat, 25 Sep 2010 09:54:21 +0000 (18:54 +0900)]
benchmarks/new_object.pl [new file with mode: 0644]

diff --git a/benchmarks/new_object.pl b/benchmarks/new_object.pl
new file mode 100644 (file)
index 0000000..531df8c
--- /dev/null
@@ -0,0 +1,33 @@
+#!perl -w
+use strict;
+use Benchmark qw(:all);
+{
+    package MyMoose;
+    use Moose;
+    has [qw(foo bar baz)] => (
+        is      => 'rw',
+        isa     => 'Str',
+        default => 'qux',
+    );
+    __PACKAGE__->meta->make_immutable();
+}
+{
+    package MyMouse;
+    use Mouse;
+    has [qw(foo bar baz)] => (
+        is      => 'rw',
+        isa     => 'Str',
+        default => 'qux',
+    );
+    __PACKAGE__->meta->make_immutable();
+}
+print "Class->meta->new_object x 10\n";
+cmpthese -1, {
+    Moose => sub {
+        MyMoose->meta->new_object() for 10;
+    },
+    Mouse => sub {
+        MyMouse->meta->new_object() for 10;
+    },
+};
+