Sha256: 44aba7ceb243a02909dc4d1f0e35e04b2a3b48e9d4e2c102d9e3149c78399731

Contents?: true

Size: 728 Bytes

Versions: 9

Compression:

Stored size: 728 Bytes

Contents

require "spec_helper"
MetricFu.metrics_require { "hotspots/analysis/ranking" }

describe MetricFu::Ranking do
  context "with many items" do
    specify "#top" do
      ranking = Ranking.new
      ranking[:a] = 10
      ranking[:b] = 50
      ranking[:c] = 1
      expect(ranking.top).to eq([:b, :a, :c])
    end

    specify "lowest item is at 0 percentile" do
      ranking = Ranking.new
      ranking[:a] = 10
      ranking[:b] = 50
      expect(ranking.percentile(:a)).to eq(0)
    end

    specify "highest item is at high percentile" do
      ranking = Ranking.new
      ranking[:a] = 10
      ranking[:b] = 50
      ranking[:c] = 0
      ranking[:d] = 5
      expect(ranking.percentile(:b)).to eq(0.75)
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
metric_fu-4.13.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
fastruby-metric_fu-5.0.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
code_metric_fu-4.14.4 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
code_metric_fu-4.14.3 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
code_metric_fu-4.14.2 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
code_metric_fu-4.14.1 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
code_metric_fu-4.14.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.12.0 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb
metric_fu-4.11.4 spec/metric_fu/metrics/hotspots/analysis/ranking_spec.rb