Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Tiny speed-up #6
I'm being lazy and submitting an issue rather than a pull request.
Line 21 is currently:
It could be:
This would slightly speed up Class::Tiny::Antlers, which calls Class::Tiny::import to do its stuff even before attributes are created.
pushed a commit
Sep 5, 2013
I benchmarked several light-weight class builder modules. (Creating Object, Accessor)
Class::Accessor::Fast vs Class::Tiny
Mo vs Class::Tiny
Class::Tiny is significantly slower than the others.
Possibly, but Class::Tiny is optimized for size, not speed. Plus, it's not feature set compatible. Class::Tiny constructor takes hashref or list, does validation, checks for BUILD, etc. The accessors support lazy defaults, etc.
Maybe the accessor could be adaptive and not have the extra check for setting the lazy default if none was given for that attribute. But that's only saving a single
I've pushed some commits that speed things up for simple cases, particularly for accessors without defaults.
Note as well that Class::Tiny supports DEMOLISH, so DESTROY gets called for every object in the benchmark, which Mo and CAF don't do.
I have a couple more minor ideas, but I think I'm near the point of diminishing returns.