Use real test data in dummy 1
This commit is contained in:
parent
1bb69bcda2
commit
689e5550ff
34
testdummy.rb
34
testdummy.rb
|
@ -1,28 +1,13 @@
|
||||||
require 'RMagick'
|
require 'RMagick'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
include Magick
|
include Magick
|
||||||
|
|
||||||
# Create a dummy list including 300 cores, with a load between 0 and 100
|
data = JSON::load(File.new('load_values.json', 'r'))
|
||||||
numberGenerator = Random.new()
|
|
||||||
|
|
||||||
# heatmap over 5 minutes by one measure per 5 sec
|
# prepare data
|
||||||
dummyList = Array.new(60) do
|
dummyList = Array.new()
|
||||||
# 16 dummy cores
|
data.each do |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
|
|
||||||
|
|
||||||
# Add all loads to compute how much % is one % load
|
# Add all loads to compute how much % is one % load
|
||||||
loadSum = 0
|
loadSum = 0
|
||||||
|
@ -31,7 +16,7 @@ dummyList = Array.new(60) do
|
||||||
|
|
||||||
# every 10 load percent one heatpoint
|
# every 10 load percent one heatpoint
|
||||||
i = 0
|
i = 0
|
||||||
Array.new(10) do
|
dummyList << Array.new(10) do
|
||||||
# get all cores in the certain percentage
|
# get all cores in the certain percentage
|
||||||
selectedCores= cores.select { |core| core >= i and core < (i+10)}
|
selectedCores= cores.select { |core| core >= i and core < (i+10)}
|
||||||
# (go to next level here)
|
# (go to next level here)
|
||||||
|
@ -41,12 +26,16 @@ dummyList = Array.new(60) do
|
||||||
selectedCores.each { |core| loadSum = loadSum + core }
|
selectedCores.each { |core| loadSum = loadSum + core }
|
||||||
percent = loadSum*percentLoad
|
percent = loadSum*percentLoad
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# puts dummyList.inspect
|
# puts dummyList.inspect
|
||||||
|
|
||||||
|
# image size
|
||||||
|
x = dummyList.length*15
|
||||||
|
|
||||||
# start drawing the damn thing
|
# 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
|
i = 0
|
||||||
dummyList.each do |point|
|
dummyList.each do |point|
|
||||||
|
@ -65,3 +54,4 @@ dummyList.each do |point|
|
||||||
end
|
end
|
||||||
|
|
||||||
loadImg.display
|
loadImg.display
|
||||||
|
# loadImg.write('loadimage.png')
|
||||||
|
|
Loading…
Reference in New Issue