Sha256: d0bcb9fee4bc51aaaca9c5bab45d7fd8fa2e0265534f2ce157e1fef09e39b23a

Contents?: true

Size: 846 Bytes

Versions: 1

Compression:

Stored size: 846 Bytes

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

if ARGV.include?('-h') || ARGV.include?('--help')
  puts "Usage: same as main `rubocop` command but gathers profiling info"
  puts "Additional option: `--memory` to print memory usage"
  exit(0)
end
with_mem = ARGV.delete('--memory')

require 'stackprof'
if with_mem
  require 'memory_profiler'
  MemoryProfiler.start
end
StackProf.start
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
begin
  load "#{__dir__}/../exe/rubocop"
ensure
  delta = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
  puts "Finished in #{delta.round(1)} seconds"
  StackProf.stop
  if with_mem
    puts "Building memory report..."
    report = MemoryProfiler.stop
  end
  Dir.mkdir('tmp') unless File.exist?('tmp')
  StackProf.results('tmp/stackprof.dump')
  report&.pretty_print(scale_bytes: true)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.88.0 bin/rubocop-profile