Sha256: 4ebdb24d9bb83b88fbd1ea5d9b92457eb86d7d16ffde763b3119cedcdeead2d0

Contents?: true

Size: 957 Bytes

Versions: 3

Compression:

Stored size: 957 Bytes

Contents

# frozen_string_literal: true

# NOTE: Gem is only active if REQUIRE_BENCH=true is set in shell

# require 'require_bench/tasks'
# will give you the require_bench tasks.
#  Do it as early as possible during bootstrapping!
require 'require_bench'

namespace :require_bench do
  desc 'Print timings while booting app, determine slowest loading files'
  task hello: :environment do
    tot  = 0.0
    vals = RequireBench::TIMINGS.to_a
    vals.sort_by! { |a| a[1] }.reverse!
    if !vals.empty?
      puts "\n[RequireBench] Slowest Loads by Library, in order"
      vals.each_with_index do |a, index|
        tot += a[1]
        printf("%2d. %10f %s\n", index + 1, a[1], a[0])
      end
      puts '=========='
      printf("%10f %s\n", tot, 'TOTAL')
    else
      puts %(
require_bench did not track any requires, because it was required too late.
Require in Rakefile, as follows
  require 'bundler/setup'
  require 'require_bench/tasks'
)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
require_bench-1.0.3 lib/require_bench/tasks.rb
require_bench-1.0.2 lib/require_bench/tasks.rb
require_bench-1.0.1 lib/require_bench/tasks.rb