3 ms·
How on earth can pathname handling be a performance drag? If I read his stats correctly, then `Pathname#chop_basename` is called 24456 times for one page load.
by bjourne 10y ago
How on earth can pathname handling be a performance drag? If I read his stats correctly, then `Pathname#chop_basename` is called 24456 times for one page load. Something is very fishy about that.
- viraptor 10y agoAgree, and that's per actual page load. Not at the start of the app. If there's no dynamic searching for paths in the app, I don't understand why there would be even one path operation done after the first request. Templates, extra resources, etc. - you can optimise this down to assembler, but it's always going to take time. What solves this is just caching the results - you don't run the path operations anymore.
- ape4 10y agoExactly what I was thinking. You look for the last slash and truncate.
- ugexe 10y agoThis is a naive solution. Try using that on windows.
- ajmurmann 10y agoThis actually makes me wonder if it would be worthwhile to look for this and similar issues and remove Windows support from the methods for a custom implementation. It might shave off some more time.
- ape4 10y agoStill, use a pattern to find the last slash or backslash. Should be pretty quick.
- deleted 10y ago[deleted]