Welcome to mirror list, hosted at ThFree Co, Russian Federation.

rubocop-profile « bin - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d1e31edbeed6854188568232550e79ecf787350b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env ruby
# frozen_string_literal: true

# Profile bundled RuboCop version.
#
# See https://github.com/rubocop/rubocop/blob/master/bin/rubocop-profile

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')
ARGV.unshift '--cache', 'false' unless ARGV.include?('--cache')

require 'stackprof'
if with_mem
  require 'memory_profiler'
  MemoryProfiler.start
end
StackProf.start
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
begin
  require 'rubocop'

  exit RuboCop::CLI.new.run
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)
  puts "StackProf written to `tmp/stackprof.dump`."
end