<commit_before>require "overall_request_times/version"
require "overall_request_times/timer"
require "overall_request_times/faraday_middleware"
require "overall_request_times/generic_timer"
require "overall_request_times/rails_middleware"
require "overall_request_times/railtie" if defined?(Rails)

module OverallRequestTimes
  def self.wipeout_registry
    @registry = nil
  end

  def self.registry
    @registry ||= {}
  end

  def self.reset!
    registry.each { |_, timer| timer.reset! }
  end

  def self.register(timer)
    registry[timer.remote_app_name] ||= timer
  end

  def self.total_for(remote_app_name)
    timer = registry[remote_app_name]
    timer ? timer.total : 0
  end

  def self.bm(remote_app_name, &block)
    start(remote_app_name)
    begin
      block.call
    ensure
      stop(remote_app_name)
    end
  end

  def self.start(remote_app_name)<commit_msg>Use autoload<commit_after>require "overall_request_times/version"
require "overall_request_times/railtie" if defined?(Rails)

module OverallRequestTimes
  autoload :Timer, "overall_request_times/timer"
  autoload :FaradayMiddleware, "overall_request_times/faraday_middleware"
  autoload :GenericTimer, "overall_request_times/generic_timer"
  autoload :RailsMiddleware, "overall_request_times/rails_middleware"

  def self.wipeout_registry
    @registry = nil
  end

  def self.registry
    @registry ||= {}
  end

  def self.reset!
    registry.each { |_, timer| timer.reset! }
  end

  def self.register(timer)
    registry[timer.remote_app_name] ||= timer
  end

  def self.total_for(remote_app_name)
    timer = registry[remote_app_name]
    timer ? timer.total : 0
  end

  def self.bm(remote_app_name, &block)
    start(remote_app_name)
    begin
      block.call
    ensure
      stop(remote_app_name)
    end
  end

  def self.start(remote_app_name)
{'fraction_non_alphanumeric': 0.08591625883632409, 'fraction_numerical': 0.001087547580206634, 'mean_word_length': 4.2421652421652425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4484561', 'n_tokens_mistral': 642, 'n_tokens_neox': 623, 'n_words': 116}