banister / method_source

return the sourcecode for a method
MIT License
361 stars 43 forks source link

Make `extract_last_comment` 65x faster #77

Closed symwell closed 2 years ago

symwell commented 2 years ago

Closed. Superceded by https://github.com/banister/method_source/pull/78

In extract_last_comment don't go over all lines of the file if the last comment is in the last 100 lines.

When used with a benchmark that called extract_last_comment 56411 times:

I tried to tune this with a different threshold, like 50-80 lines or 150-500 lines, and ~100 lines worked well for the benchmark used.