0
0
Fork 0
rubella/lib/rubella/weighting/expotential.rb

44 lines
1.2 KiB
Ruby

require "rubella/weighting/base"
module Rubella
module Weighting
# The Rubella::Weighting::Expotential object weights every bucket per
# amount of cores. But the cores with higher load get a visualisation
# boost, which is expotential. So one high load core, will have much more
# color, than serveral less load cores.
#
class Expotential < Base
# Creates a output readable list.
# This list is Array within a subarrays, which contain the buckets for
# every time value unit.
#
# @param input Rubella::Input An input object
# @return Rubella::Storage
def parse input
# prepare data
data_list = Array.new()
bucket_no = 0
input.each do |cores|
# every 10 load percent one heatpoint
i = 0
data_list << Array.new(buckets) do
amount = cores.select { |core| core >= i and core < (i+@steps)}.length
i = i + @steps
core = (amount.to_f*bucket_no**0.8)/cores.length
bucket_no = bucket_no + 1
core
end
end
Rubella::Storage.new data_list
end
end
end
end