From bf63612bbc4e145d6ae5e5c31b97a55c501abc35 Mon Sep 17 00:00:00 2001 From: Stormwind Date: Sat, 1 Jun 2013 12:37:04 +0200 Subject: [PATCH] Use real test data for dummy 2 --- testdummy2.rb | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/testdummy2.rb b/testdummy2.rb index 865b3fe..f98088f 100644 --- a/testdummy2.rb +++ b/testdummy2.rb @@ -1,32 +1,18 @@ require 'RMagick' +require 'json' include Magick -# Create a dummy list including 300 cores, with a load between 0 and 100 -numberGenerator = Random.new() +data = JSON::load(File.new('load_values.json', 'r')) +weigthOfOneCore = 127.5/data[0].length -# heatmap over 5 minutes by one measure per 5 sec -dummyList = Array.new(60) do - # 16 dummy cores - # lets say 10 cores have a load up to 10% - # 4 have a load up to 30% - # and 2 have a load up to 100% - j = 0 - cores = Array.new(16) do - j = j + 1 - case - when j <= 10 - numberGenerator.rand(10) - when (j >= 11 and j <= 14) - numberGenerator.rand(30) - when (j >= 15 and j <= 16) - numberGenerator.rand(100) - end - end +# prepare data +dummyList = Array.new() +data.each do |cores| # every 10 load percent one heatpoint i = 0 - Array.new(10) do + dummyList << Array.new(10) do amount = cores.select { |core| core >= i and core < (i+10)}.length i = i + 10 amount @@ -35,8 +21,11 @@ end # puts dummyList.inspect +# image size +x = dummyList.length*15 + # start drawing the damn thing -loadImg = Image.new(900,150) { self.background_color = "white" } +loadImg = Image.new(x,150) { self.background_color = "white" } i = 0 dummyList.each do |point| @@ -46,8 +35,7 @@ dummyList.each do |point| # draw a red rectangle on the white background core = Draw.new - weightedCores = 0 - weightedCores = k**0.8*cores*7.96875 if cores != 0 + weightedCores = k**0.8*cores*weigthOfOneCore weightedCores = 127.5 if weightedCores > 127.5 l = (255-weightedCores).round core.fill(Pixel.from_hsla(0, 255, l, 1).to_color) @@ -60,3 +48,4 @@ dummyList.each do |point| end loadImg.display +# loadImg.write('loadimage2.png')