Sha256: 1706804a3ef045254c10ed0bd6072ec490cad0fb99758d6768de5478835a6d05

Contents?: true

Size: 864 Bytes

Versions: 169

Compression:

Stored size: 864 Bytes

Contents

# typed: true
# frozen_string_literal: true

module T::Profile
  SAMPLE_RATE = 101 # 1 out of that many typechecks will be measured
  class <<self
    attr_accessor :typecheck_duration
    attr_accessor :typecheck_samples
    attr_accessor :typecheck_sample_attempts
    def typecheck_duration_estimate
      total_typechecks = typecheck_samples * SAMPLE_RATE + (SAMPLE_RATE - typecheck_sample_attempts)
      typechecks_measured = typecheck_samples * SAMPLE_RATE
      if typechecks_measured.positive?
        typecheck_duration * SAMPLE_RATE * 1.0 * total_typechecks / typechecks_measured
      else
        0.0
      end
    end

    def typecheck_count_estimate
      typecheck_samples * SAMPLE_RATE
    end

    def reset
      @typecheck_duration = 0
      @typecheck_samples = 0
      @typecheck_sample_attempts = SAMPLE_RATE
    end
  end
  self.reset
end

Version data entries

169 entries across 169 versions & 1 rubygems

Version Path
sorbet-runtime-0.5.6212 lib/types/profile.rb
sorbet-runtime-0.5.6210 lib/types/profile.rb
sorbet-runtime-0.5.6206 lib/types/profile.rb
sorbet-runtime-0.5.6205 lib/types/profile.rb
sorbet-runtime-0.5.6203 lib/types/profile.rb
sorbet-runtime-0.5.6198 lib/types/profile.rb
sorbet-runtime-0.5.6196 lib/types/profile.rb
sorbet-runtime-0.5.6193 lib/types/profile.rb
sorbet-runtime-0.5.6189 lib/types/profile.rb
sorbet-runtime-0.5.6188 lib/types/profile.rb
sorbet-runtime-0.5.6187 lib/types/profile.rb
sorbet-runtime-0.5.6183 lib/types/profile.rb
sorbet-runtime-0.5.6173 lib/types/profile.rb
sorbet-runtime-0.5.6164 lib/types/profile.rb
sorbet-runtime-0.5.6161 lib/types/profile.rb
sorbet-runtime-0.5.6155 lib/types/profile.rb
sorbet-runtime-0.5.6154 lib/types/profile.rb
sorbet-runtime-0.5.6145 lib/types/profile.rb
sorbet-runtime-0.5.6141 lib/types/profile.rb
sorbet-runtime-0.5.6140 lib/types/profile.rb