diff --git a/lib/rubella/weighting/exponential.rb b/lib/rubella/weighting/exponential.rb deleted file mode 100644 index ff8420b..0000000 --- a/lib/rubella/weighting/exponential.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Rubella - module Weighting - - class Expotential - end - - end -end diff --git a/lib/rubella/weighting/expotential.rb b/lib/rubella/weighting/expotential.rb new file mode 100644 index 0000000..5034eb6 --- /dev/null +++ b/lib/rubella/weighting/expotential.rb @@ -0,0 +1,50 @@ +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 + data = input.data + # no data, no work + return [] if data.length == 0 + + # total amount of cores + total_amount = data[0].length + + # prepare data + data_list = Array.new() + bucket_no = 0 + + data.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)/total_amount + bucket_no = bucket_no + 1 + + core + end + end + + Rubella::Storage.new data_list + end + + end + + end +end