whitequark / parser

A Ruby parser.
Other
1.57k stars 197 forks source link

Remove `benchmark` dependency from the runner #1038

Closed Earlopain closed 2 weeks ago

Earlopain commented 2 weeks ago

Ruby wants to bundle it: https://github.com/ruby/ruby/pull/11492, which means that the next ruby release will warn and the one after that will error, unless it is added to the gemspec. Usage is trivial and can simply be inlined.

The benchmark gem does it like this for 14 years already so I don't imagine compatibility problems with older ruby versions: https://github.com/ruby/benchmark/blame/0383673a9089d6a74a73ef37c67d5afc15d66d71/lib/benchmark.rb#L277-L287

Test with bin/ruby-parse lib/parser/ruby34.rb --bench.

iliabylich commented 2 weeks ago

Thanks. Do you know whether Process.times.utime uses monotonic time? If not could you replace it with Process.clock_gettime(Process::CLOCK_MONOTONIC) please?

Earlopain commented 2 weeks ago

I believe it is but CLOCK_MONOTONIC seems more correct anyways. You basically want the cumulative of these https://ruby-doc.org/3.3.4/Process.html#method-c-times. I don't think it matters much in this context butI switched it over :+1:

iliabylich commented 2 weeks ago

Thank you very much!