-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only use Type::Tiny (no Mo*se) #85
base: master
Are you sure you want to change the base?
Conversation
mst requested that I add a reference here back to the original discussion (#81) as to what further work I need to do before I can address this pull request. To sum up:
|
Well, I finally got a chance to do the performance testing at least. Curious results:
(Results using Dumbbench.) Now, to be fair, this is a benchmark of functions that do nothing other than validate their parameters, which is something I specifically rail against in my own first MS talk. So I think these numbers are only useful in a relative sense, which is all I was looking for anyway, which is why I didn't bother to try to simulate anything more complex. So here's what I take out of it:
So this is not going to keep me from moving forwards. But I thought it was interesting enough to share. |
hi, thank you for the benchmark. I agree with you that we an work on optimizing Type::Tiny later on if needed. Although I suspect @tobyink to already have given it a good thought. |
Mouse's core type constraints are implemented in C. If Mouse is loaded early enough, Type::Tiny will actually borrow its C For custom types, Mouse is generally slower than either Type::Tiny or
I think currently the Method::Signatures code calls An easy win would be:
This saves a method lookup and an extra sub call. (And when Mouse is -Toby |
Well, our internal signature object is a Mouse object, so Mouse is definintely going to get loaded. Is there any to insure it's loaded early enough, since apparently it wasn't in my stupid/simple benchmark? or is that dependent on the client's code?
Okay, that's a fair point: I was only testing built-in types (Str, Int, ArrayRef).
Okay, that sounds pretty cool. Perhaps I'll fiddle around with that. Are there any gotchas I need to be aware of there? any time when the compiled_check can get stale, or any situation where it might fail to return anything at all?
I think GitHub ate your attachment. :-D Put it in a gist, perhaps? |
Basically the first time a type constraint is checked, if Mouse is already
The compiled check will always return a usable coderef. The $type->check
Which is why grabbing and using the compiled_check directly is faster - it
https://gist.github.com/tobyink/7416390 -Toby |
So, After discussion with @barefootcoder and @tobyink, I've produced this experimentation: have Method::Signature only use Type::Tiny for type checking.
It actually works very well.
With the help of @tobyink, the last bug is fixed ( when using a class name, it was currently translated to the type
Object
instead ofInstanceOf[Foo::Bar]
).