mach5-tools 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/TODO +8 -4
- data/VERSION +1 -1
- data/bin/mach5 +17 -0
- data/lib/mach5-tools/benchmark.rb +4 -0
- data/lib/mach5-tools/chart.rb +62 -0
- data/lib/mach5-tools/config.rb +69 -0
- data/lib/mach5-tools/js/chart.html +21 -0
- data/lib/mach5-tools/js/chart.js +58 -0
- data/lib/mach5-tools/js/highcharts.js +294 -0
- data/lib/mach5-tools/js/jquery.js +2 -0
- data/lib/mach5-tools/runner.rb +71 -29
- data/lib/mach5-tools.rb +2 -1
- data/mach5-tools.gemspec +9 -3
- data/spec/chart_spec.rb +49 -0
- data/spec/config_spec.rb +46 -0
- data/spec/runner_spec.rb +9 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d531491376f7d66a0280e9383c5ad05cb2370ba1
|
4
|
+
data.tar.gz: ed0e957e907164e64b17317f7ade8f8e09034433
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bbfe9364b097465db0285a1ae7f2f0dd9beccba1613376783f3924ec2c5d0375ca244bc8f8f6281e50651c4cac2a954bad7ae36987f961a7e8a7e341fd59fcf
|
7
|
+
data.tar.gz: 85c0f626d38a433c5df81684e4f90524cf7e0a3651a3ba0f1c5c5ab11f93bc3debac5343d922702153b0b12c14d0bf9df52c713252c28e9faef5ed3b21354733
|
data/TODO
CHANGED
@@ -3,10 +3,14 @@ v0.1.0
|
|
3
3
|
[x] mach5 benchmark --only commit_id.benchmark
|
4
4
|
|
5
5
|
v0.2.0
|
6
|
-
[
|
7
|
-
[
|
8
|
-
[
|
9
|
-
[
|
6
|
+
[x] mach5 chart
|
7
|
+
[x] mach5 chart --all
|
8
|
+
[x] mach5 chart --list (lista e mostrar o status: se ja existe ou nao)
|
9
|
+
[x] mach5 chart --only graph_id
|
10
|
+
[x] charts com tags
|
11
|
+
[x] mais opções para add_serie
|
12
|
+
[x] mais opções para x_axis e y_axis
|
13
|
+
[x] definir o tipo do grafico (line ou bar)
|
10
14
|
|
11
15
|
v0.3.0
|
12
16
|
[ ] mach5 init (cria o Mach5file)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/mach5
CHANGED
@@ -23,6 +23,23 @@ class App < Thor
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
desc "chart", "Generate charts"
|
27
|
+
method_option :all, :type => :boolean, :aliases => "-a", :desc => "Generates all benchmarks even if it was already generated"
|
28
|
+
method_option :list, :type => :boolean, :aliases => "-l", :desc => "List all available charts"
|
29
|
+
method_option :only, :type => :array, :aliases => "-o", :desc => "Generates only the specified charts"
|
30
|
+
def chart
|
31
|
+
runner = Mach5::Runner.new(eval(File.open("Mach5file").readlines.join))
|
32
|
+
if options.list
|
33
|
+
runner.list_charts.each do |chart|
|
34
|
+
puts chart
|
35
|
+
end
|
36
|
+
elsif options.only
|
37
|
+
runner.chart(only: options.only)
|
38
|
+
else
|
39
|
+
runner.chart(all: options.all)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
26
43
|
default_task :benchmark
|
27
44
|
end
|
28
45
|
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Mach5
|
2
|
+
class Chart
|
3
|
+
attr_accessor :type
|
4
|
+
attr_accessor :data_type
|
5
|
+
attr_accessor :size
|
6
|
+
attr_accessor :title
|
7
|
+
attr_accessor :x_axis
|
8
|
+
attr_accessor :y_axis
|
9
|
+
attr_accessor :series
|
10
|
+
attr_accessor :config
|
11
|
+
attr_reader :id
|
12
|
+
|
13
|
+
def initialize(id)
|
14
|
+
@id = id
|
15
|
+
end
|
16
|
+
|
17
|
+
def build
|
18
|
+
hash = {
|
19
|
+
"type" => @type,
|
20
|
+
"dataType" => @data_type,
|
21
|
+
"size" => {
|
22
|
+
"width" => size.split("x").map(&:to_i)[0],
|
23
|
+
"height" => size.split("x").map(&:to_i)[1]
|
24
|
+
},
|
25
|
+
"title" => {
|
26
|
+
"text" => @title
|
27
|
+
},
|
28
|
+
"xAxis" => {
|
29
|
+
"title" => {
|
30
|
+
"text" => @x_axis[:label]
|
31
|
+
}
|
32
|
+
},
|
33
|
+
"yAxis" => {
|
34
|
+
"title" => {
|
35
|
+
"text" => @y_axis
|
36
|
+
}
|
37
|
+
},
|
38
|
+
"series" => _series(@series)
|
39
|
+
}
|
40
|
+
hash["xAxis"]["categories"] = @x_axis[:categories] if @x_axis[:categories]
|
41
|
+
hash
|
42
|
+
end
|
43
|
+
|
44
|
+
def _series(series)
|
45
|
+
result = []
|
46
|
+
series.each do |s|
|
47
|
+
commit_id = @config.benchmarks.tagged[s[:commit_id]]
|
48
|
+
unless commit_id
|
49
|
+
commit_id = s[:commit_id]
|
50
|
+
end
|
51
|
+
serie = {
|
52
|
+
"label" => "#{s[:commit_id]}.#{s[:benchmark_id]}",
|
53
|
+
"file" => File.join(Dir.pwd, @config.output_folder, "#{commit_id}.#{s[:benchmark_id]}.json")
|
54
|
+
}
|
55
|
+
serie["label"] = s[:label] if s[:label]
|
56
|
+
serie["color"] = s[:color] if s[:color]
|
57
|
+
result << serie
|
58
|
+
end
|
59
|
+
result
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/lib/mach5-tools/config.rb
CHANGED
@@ -10,10 +10,13 @@ module Mach5
|
|
10
10
|
attr_accessor :project_name
|
11
11
|
attr_accessor :output_folder
|
12
12
|
attr_accessor :benchmarks
|
13
|
+
attr_accessor :charts
|
13
14
|
|
14
15
|
def initialize(project_name, block)
|
15
16
|
@project_name = project_name
|
16
17
|
@benchmarks = Benchmark.new(Hash.new, Hash.new)
|
18
|
+
@charts = []
|
19
|
+
@output_folder = "_benchmark"
|
17
20
|
instance_eval(&block)
|
18
21
|
end
|
19
22
|
|
@@ -47,5 +50,71 @@ module Mach5
|
|
47
50
|
def exec(command)
|
48
51
|
@commands << command
|
49
52
|
end
|
53
|
+
|
54
|
+
def chart(chart_id, &block)
|
55
|
+
@chart_series = []
|
56
|
+
@chart_type = "line"
|
57
|
+
@chart_size = "700x500"
|
58
|
+
@chart_title = "Benchmark"
|
59
|
+
@chart_x_axis = "X"
|
60
|
+
@chart_y_axis = "Y"
|
61
|
+
@data_type = "runs_total_time"
|
62
|
+
instance_eval(&block)
|
63
|
+
chart = Chart.new(chart_id)
|
64
|
+
chart.data_type = @data_type
|
65
|
+
chart.type = @chart_type
|
66
|
+
chart.size = @chart_size
|
67
|
+
chart.title = @chart_title
|
68
|
+
chart.x_axis = @chart_x_axis
|
69
|
+
chart.y_axis = @chart_y_axis
|
70
|
+
chart.series = @chart_series
|
71
|
+
chart.config = self
|
72
|
+
@charts << chart
|
73
|
+
end
|
74
|
+
|
75
|
+
def title(str)
|
76
|
+
@chart_title = str
|
77
|
+
end
|
78
|
+
|
79
|
+
def add_serie(benchmark, &block)
|
80
|
+
@serie_label = nil
|
81
|
+
@serie_color = nil
|
82
|
+
block.call if block
|
83
|
+
@chart_series << {commit_id: benchmark.keys[0], benchmark_id: benchmark.values[0], label: @serie_label, color: @serie_color}
|
84
|
+
end
|
85
|
+
|
86
|
+
def data_type(type)
|
87
|
+
@data_type = type
|
88
|
+
end
|
89
|
+
|
90
|
+
def x_axis(label, &block)
|
91
|
+
@chart_x_axis_categories = nil
|
92
|
+
block.call if block
|
93
|
+
@chart_x_axis = {label: label, categories: @chart_x_axis_categories}
|
94
|
+
end
|
95
|
+
|
96
|
+
def y_axis(label)
|
97
|
+
@chart_y_axis = label
|
98
|
+
end
|
99
|
+
|
100
|
+
def size(str)
|
101
|
+
@chart_size = str
|
102
|
+
end
|
103
|
+
|
104
|
+
def type(str)
|
105
|
+
@chart_type = str
|
106
|
+
end
|
107
|
+
|
108
|
+
def label(str)
|
109
|
+
@serie_label = str
|
110
|
+
end
|
111
|
+
|
112
|
+
def color(str)
|
113
|
+
@serie_color = str
|
114
|
+
end
|
115
|
+
|
116
|
+
def categories(cat)
|
117
|
+
@chart_x_axis_categories = cat
|
118
|
+
end
|
50
119
|
end
|
51
120
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
7
|
+
<title>Line Chart</title>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div id="container" style="width:100%; height:100%;"></div>
|
11
|
+
<script src="jquery.js"></script>
|
12
|
+
<script src="highcharts.js"></script>
|
13
|
+
<script type="text/javascript">
|
14
|
+
$('#container').height($(document).height());
|
15
|
+
$(window).resize(function() {
|
16
|
+
console.log($(window).height());
|
17
|
+
$('#container').height($(window).height());
|
18
|
+
});
|
19
|
+
</script>
|
20
|
+
</body>
|
21
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
var page = require('webpage').create(),
|
2
|
+
system = require('system'),
|
3
|
+
fs = require('fs');
|
4
|
+
|
5
|
+
page.viewportSize = { width: 960, height: 540 };
|
6
|
+
|
7
|
+
var process_data = function(data, type) {
|
8
|
+
var table = new Array();
|
9
|
+
table[0] = new Array();
|
10
|
+
table[1] = new Array();
|
11
|
+
for (var i = 0; i < data.length; i++) {
|
12
|
+
table[0][i] = data[i].index;
|
13
|
+
table[1][i] = data[i][type];
|
14
|
+
}
|
15
|
+
return table;
|
16
|
+
}
|
17
|
+
|
18
|
+
var descriptor = eval(system.args[2])[0],
|
19
|
+
current_path = system.args[1],
|
20
|
+
output_image = system.args[3];
|
21
|
+
|
22
|
+
if (typeof descriptor.size !== "undefined")
|
23
|
+
page.viewportSize = descriptor.size;
|
24
|
+
|
25
|
+
page.open(current_path + '/chart.html', function() {
|
26
|
+
for (var i = 0; i < descriptor.series.length; i++) {
|
27
|
+
var file = fs.open(descriptor.series[i].file, 'r');
|
28
|
+
descriptor.series[i].data = eval(file.read());
|
29
|
+
}
|
30
|
+
|
31
|
+
page.evaluate(function(process_data, descriptor) {
|
32
|
+
$(function () {
|
33
|
+
var series = new Array();
|
34
|
+
for (var i = 0; i < descriptor.series.length; i++) {
|
35
|
+
series[i] = {
|
36
|
+
name: descriptor.series[i].label,
|
37
|
+
data: process_data(descriptor.series[i].data, descriptor.dataType)[1],
|
38
|
+
color: descriptor.series[i].color,
|
39
|
+
animation: false
|
40
|
+
};
|
41
|
+
}
|
42
|
+
|
43
|
+
$('#container').highcharts({
|
44
|
+
chart: {
|
45
|
+
type: descriptor.type,
|
46
|
+
animation: false
|
47
|
+
},
|
48
|
+
title: descriptor.title,
|
49
|
+
xAxis: descriptor.xAxis,
|
50
|
+
yAxis: descriptor.yAxis,
|
51
|
+
series: series
|
52
|
+
});
|
53
|
+
});
|
54
|
+
}, process_data, descriptor);
|
55
|
+
|
56
|
+
page.render(output_image);
|
57
|
+
phantom.exit();
|
58
|
+
});
|