icyleaf / fast-crystal

💨 Writing Fast Crystal 😍 -- Collect Common Crystal idioms.
MIT License
166 stars 8 forks source link

add more detailed infos/ notes/ possible advice #3

Open ghost opened 7 years ago

ghost commented 7 years ago

could be nice to add inline code notes e.g. dup vs clone where clone duplicates values, which explains why it is slower

on the parts where performance is identical it would be ideal to compare IR code additionally and then potentially eliminate the "slower/ fastet statement" where it is only because of measurement errors

general things like "tuple is faster than array, tuple is like struct" would be good (with a note that struct is stack allocated)

the regexp comparison could be expanded by a third option where the regexp object is created before the benchmark, see your markdown parser

thanks for the compilation of tests though, something to keep in mind at times

decal commented 4 years ago

This could be taken a step further by providing possible code refactoring rules (perhaps with a tool like comby.dev). They could be sorted by speed and rated by other code metrics such as readability, brevity, security, etc. However, automating such transformations may be outside of the author's originally intended scope for fast-crystal.