diff --git a/cpu_load_demo.html b/cpu_load_demo.html new file mode 100644 index 0000000..9d4e57e --- /dev/null +++ b/cpu_load_demo.html @@ -0,0 +1,34 @@ + + + + + + + + +This is the CPU load + + + \ No newline at end of file diff --git a/git-history.rb b/git-history.rb new file mode 100644 index 0000000..8489d8e --- /dev/null +++ b/git-history.rb @@ -0,0 +1,34 @@ +require "git" +require "rubella" +require "rubella/output/image" +require "rubella/weighting/per_count" + +# Get git history +repository = Git.open("../rubella/") +git_log = repository.log(1000000).since('1 year ago') + +# Create an commit per day array +current_date = Time.now +commits_per_day = Array.new(1, 0) +git_log.each do |commit| + # Insert 0 until the date fits + until current_date.year == commit.date.year and + current_date.month == commit.date.month and + current_date.day == commit.date.day + commits_per_day.insert(0, 0) + current_date = current_date - (60*60*24) + end + commits_per_day[0] = commits_per_day.first + 1 +end + +# Give rubella this array +# Prepare classes +weighting = Rubella::Weighting::PerCount.new + +storage = weighting.parse commits_per_day + +# Get a heatmap of your commits +image = Rubella::Output::Image.new(storage, 15) +#image.background_color = "black" +image.render.write("git_commits.png") + diff --git a/streaming_load.rb b/streaming_load.rb new file mode 100644 index 0000000..0f18036 --- /dev/null +++ b/streaming_load.rb @@ -0,0 +1,61 @@ +require "rubella" +require "rubella/input/base" +require "rubella/output/image" +require "rubella/output/ascii" +require "rubella/weighting/per_value" +require "rubella/weighting/per_overall_load" +require "rubella/weighting/expotential" + +# Number of cores +cores = 8 +# Number of buckets +buckets = 10 +# Number of columns +col = 25 +# Field size +size = 50 +# Time intervall in sec. +time = 1 + +# Prepare classes +#weighting = Rubella::Weighting::PerValue.new buckets +weighting = Rubella::Weighting::PerOverallLoad.new buckets +#weighting = Rubella::Weighting::Expotential.new buckets +storage = Rubella::Storage.new Array.new(1, Array.new(cores, 0)), col + +while true + dataset = Array.new() + Random.new_seed + # Generate new dataset + i = 0 + dataset << Array.new(cores) do + core_load = 0 + case i + when 0 + core_load = 100 + when 1..2 + core_load = rand(80..100) + when 3..5 + core_load = rand(50..80) + when 7 + core_load = rand(0..15) + else + # Generate a value between 0 and 100 + core_load = rand(100) + end + i = i + 1 + core_load + end + #puts dataset.inspect + + # Push new dataset through input && Weight data && Add new data to storage + new_storage = weighting.parse(Rubella::Input::Base.new(dataset)) + #puts new_storage.data.inspect + storage = storage.add new_storage + + # Dump new image + # Rubella::Output::Image.new(storage, size).render.write("cpu_load.png") + puts Rubella::Output::ASCII.new(storage, size).render + + sleep(time) +end