Skip to content

Commit

Permalink
Remove benchmark dependency from the runner
Browse files Browse the repository at this point in the history
Ruby wants to bundle it: ruby/ruby#11492

The benchmark gem does it like this for 14 years already so I don't imagine
problems with older ruby versions
  • Loading branch information
Earlopain committed Aug 29, 2024
1 parent c7af34c commit 7a6d6d7
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lib/parser/runner.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# frozen_string_literal: true

require 'benchmark'
require 'find'
require 'optparse'

Expand Down Expand Up @@ -220,14 +219,13 @@ def input_size
end

def process_all_input
parsing_time =
Benchmark.measure do
process_fragments
process_files
end
time_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
process_fragments
process_files
time_elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - time_start

if @benchmark
report_with_time(parsing_time)
report_with_time(time_elapsed)
end
end

Expand Down Expand Up @@ -278,12 +276,10 @@ def process(buffer)
raise NotImplementedError, "implement #{self.class}##{__callee__}"
end

def report_with_time(parsing_time)
cpu_time = parsing_time.utime

speed = '%.3f' % (@source_size / cpu_time / 1000)
def report_with_time(time_elapsed)
speed = '%.3f' % (@source_size / time_elapsed / 1000)
puts "Parsed #{@source_count} files (#{@source_size} characters)" \
" in #{'%.2f' % cpu_time} seconds (#{speed} kchars/s)."
" in #{'%.2f' % time_elapsed} seconds (#{speed} kchars/s)."

if defined?(RUBY_ENGINE)
engine = RUBY_ENGINE
Expand Down

0 comments on commit 7a6d6d7

Please sign in to comment.