{"issue":{"pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"state":"open","user":{"avatar_url":"https://secure.gravatar.com/avatar/08c9b8c4fa5870b86f2054212261e02a?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"08c9b8c4fa5870b86f2054212261e02a","url":"https://api.github.com/users/rsimoes","login":"rsimoes","id":161220},"milestone":null,"labels":[],"assignee":null,"updated_at":"2011-10-28T20:52:58Z","closed_at":null,"comments":5,"url":"https://api.github.com/repos/schwern/method-signatures/issues/42","body":"Adapting Michael Schwern's benchmarking script mentioned in a [blog post](http://blogs.perl.org/users/michael_g_schwern/2011/03/and-the-fastest-oo-accessor-is.html), I used it to test `Method::Signatures` type constraints. According to `Method::Signature`'s documentation, the \"run-time penalty if you do declare types should be very similar to using `Mouse::Util::TypeConstraints` (or `Moose::Util::TypeConstraints`) directly.\" I may have made a mistake in my own testing, but this appears to not be the case:\r\n\r\n    Testing Perl 5.014002, Method::Signatures 20111020, Moo 0.009011, Object::InsideOut 3.84, Mouse 0.97, Moose 2.0205\r\n    Benchmark: timing 6000000 iterations of Method::Signatures, Moo, Mouse, Object::InsideOut, manual...\r\n    Method::Signatures: 17 wallclock secs (17.10 usr +  0.00 sys = 17.10 CPU) @ 350877.19/s (n=6000000)\r\n    Moo:                10 wallclock secs (10.42 usr +  0.00 sys = 10.42 CPU) @ 575815.74/s (n=6000000)\r\n    Mouse:              2 wallclock secs ( 1.97 usr +  0.00 sys =  1.97 CPU) @ 3045685.28/s (n=6000000)\r\n    Object::InsideOut:  5 wallclock secs ( 5.56 usr +  0.00 sys =  5.56 CPU) @ 1079136.69/s (n=6000000)\r\n    manual:             11 wallclock secs (10.55 usr +  0.00 sys = 10.55 CPU) @ 568720.38/s (n=6000000)\r\n    Moose:              12 wallclock secs (12.26 usr +  0.00 sys = 12.26 CPU) @ 489396.41/s (n=6000000)\r\n\r\nIn order to get `Method::Signatures` to use `Mouse`, I commented out `Moose` and then reran the test with it included (incidentally, `Method::Signature`'s time jumped to 30 seconds when it used `Moose`). My fork of the benchmark script can be found at https://gist.github.com/1321873 .","html_url":"https://github.com/schwern/method-signatures/issues/42","number":42,"title":"Performance issues with type-constraint checking","id":2076826,"created_at":"2011-10-28T09:04:15Z"},"action":"created","comment":{"user":{"avatar_url":"https://secure.gravatar.com/avatar/e55e0ec3c00f834d78fbdddeaa36e308?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"e55e0ec3c00f834d78fbdddeaa36e308","url":"https://api.github.com/users/schwern","login":"schwern","id":25888},"updated_at":"2011-10-28T20:52:58Z","url":"https://api.github.com/repos/schwern/method-signatures/issues/comments/2561035","body":"I inlined the contents of type_check().  Looks like this:\r\n\r\n    Method::Signatures->type_error('Int', $_[0], 'arg') if\r\n        !($Method::Signatures::mutc{cache}{'Int'} ||= Method::Signatures->_make_constraint('Int'))->check($_[0]);\r\n\r\nEliminating the method call slashes off 40% of the runtime when using XS Mouse and 20% with Moose.  I'm pretty happy with that. :-)\r\n\r\nMade sure to check if type_check has been overridden first.","id":2561035,"created_at":"2011-10-28T20:52:58Z"}}