mach5-tools 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cce1bb05727559d4d95becf25542e7d9334bd9fd
4
- data.tar.gz: 603d7c169a843c26666d5ce82215819fda09916e
3
+ metadata.gz: 163872e80d75ee26cc09b5a1dfc6db9c376c683f
4
+ data.tar.gz: 1bb00f92a1b7dad131528a9a5674477a3efc3f3b
5
5
  SHA512:
6
- metadata.gz: 1302656407ebbe2177d846c5bc255e93fcc816d59b5d6f4441156cabdaf016bffa1cbda13b352b31a781d8da34fc2f851125a6c396165c108f7ec5bd8da32a5f
7
- data.tar.gz: 995d488ad455d579d8a47a7a2cc3fce8a5a388f8144cfee0a1bdd7c36661bf3fb1f9335a7e69bd4a55f42c84f30347bb396638485c24d2afef3ba5976d219955
6
+ metadata.gz: 64b91ef9ccbba42e13526cdc47dff79d31280befb018a55ab4959369b51e193f83d4bacd72c730431155b3266b279de4a31bfadb16797d65560c42b0f21f2a4a
7
+ data.tar.gz: 7734d58b73c4e2ab49dc272228a2ca7aee48457954a2d3a7ef7a49db7a0dfd64622abd8bd76ac52470557398afd5554a7d62947ee930a155c7b31560ad613029
data/README.rdoc CHANGED
@@ -1,10 +1,39 @@
1
- = Mach 5 Tools
1
+ = Mach5 Tools
2
2
 
3
- It is a beta software!
3
+ Easily manage your Mach5 benchmarks.
4
4
 
5
- Mach 5 Tools is part of Mach 5 project: https://github.com/igorbonadio/mach5
5
+ == Requirements
6
6
 
7
- == Contributing to Mach 5 Tools
7
+ * Mach5 library (https://github.com/igorbonadio/mach5)
8
+ * Ruby 1.9 or 2.0 (http://www.ruby-lang.org)
9
+ * Git (http://git-scm.com)
10
+ * Phantomjs (http://phantomjs.org), if you want to generate charts
11
+
12
+ == Install
13
+
14
+ $ gem install mach5-tools
15
+
16
+ == Configuration
17
+
18
+ First you need to configure and to define benchmarks using the Mach5 library. If you want to know how to do it, check this {page}[https://github.com/igorbonadio/mach5].
19
+
20
+ After that, go to the root of your project and run
21
+
22
+ $ mach5 init
23
+
24
+ It will generate a file called Mach5file that is a template of benchmark and chart definitions. So all you need to do is edit this file.
25
+
26
+ == Usage
27
+
28
+ There are 5 available commands:
29
+
30
+ * benchmark - Run benchmarks
31
+ * chart - Generate charts
32
+ * init - Create an initial Mach5file
33
+ * version - Print the version
34
+ * help - Describe available commands or one specific command
35
+
36
+ == Contributing to Mach5 Tools
8
37
 
9
38
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
10
39
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
data/TODO CHANGED
@@ -19,5 +19,8 @@ v0.2.1
19
19
  [x] BUG: quando não existe a pasta de output, "mach5 chart" quebra
20
20
 
21
21
  v0.3.0
22
- [ ] mach5 init (cria o Mach5file)
23
-
22
+ [x] mach5 init (cria o Mach5file)
23
+ [x] mach5 --version
24
+ [x] README
25
+ [ ] Site
26
+ [ ] Apresentação
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
data/bin/mach5 CHANGED
@@ -40,6 +40,22 @@ class App < Thor
40
40
  end
41
41
  end
42
42
 
43
+ desc "version", "Print the version"
44
+ def version
45
+ puts "v#{File.open(File.join(File.dirname(__FILE__), "../VERSION")).readlines.join}"
46
+ end
47
+
48
+ desc "init", "Create an initial Mach5file"
49
+ def init
50
+ if File.exists?("Mach5file")
51
+ puts "There is already a Mach5file. If you want to overwrite it, try to remove it first and then generate a new one."
52
+ else
53
+ File.open("Mach5file", "w") do |f|
54
+ f.write(File.open(File.join(File.dirname(__FILE__), "../lib/templates/Mach5file")).readlines.join.gsub("{{PROJECT_NAME}}", File.basename(Dir.getwd)))
55
+ end
56
+ end
57
+ end
58
+
43
59
  default_task :benchmark
44
60
  end
45
61
 
data/lib/mach5-tools.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  root_path = File.expand_path(File.dirname(__FILE__))
2
2
 
3
+ require File.join(root_path, 'mach5-tools/command/benchmark')
4
+ require File.join(root_path, 'mach5-tools/command/chart')
3
5
  require File.join(root_path, 'mach5-tools/benchmark')
4
6
  require File.join(root_path, 'mach5-tools/config')
5
7
  require File.join(root_path, 'mach5-tools/runner')
@@ -0,0 +1,88 @@
1
+ module Mach5
2
+ module Command
3
+ module Benchmark
4
+ def run(benchmarks)
5
+ results = ""
6
+ @config.run_commands.each do |command|
7
+ output = IO.popen "#{command} --color --json run #{benchmarks.join(' ')}"
8
+ results = output.readlines.join
9
+ end
10
+ JSON.parse(results)
11
+ end
12
+
13
+ def checkout(commit_id)
14
+ Kernel.system "git checkout #{commit_id}"
15
+ end
16
+
17
+ def _only_benchmarks(benchmarks)
18
+ @config.benchmarks.commits.each do |commit|
19
+ selected_benchmarks = _select_benchmarks(commit, @config.benchmarks.has_tag?(commit), benchmarks)
20
+ _run_benchmarks(selected_benchmarks, commit) if selected_benchmarks.size > 0
21
+ end
22
+ end
23
+
24
+ def _select_benchmarks(commit, commit_id, benchmarks)
25
+ selected_benchmarks = []
26
+ @config.benchmarks[commit].each do |benchmark|
27
+ without_tag = "#{commit}.#{benchmark}"
28
+ with_tag = "#{commit_id}.#{benchmark}"
29
+ selected_benchmarks << benchmark if benchmarks.include?(without_tag)
30
+ selected_benchmarks << benchmark if benchmarks.include?(with_tag) and commit_id
31
+ end
32
+ selected_benchmarks
33
+ end
34
+
35
+ def _all_benchmarks
36
+ @config.benchmarks.commits.each do |commit|
37
+ checkout(commit)
38
+ before
39
+ save(run(@config.benchmarks[commit]), commit)
40
+ after
41
+ end
42
+ end
43
+
44
+ def _only_new_benchmarks
45
+ @config.benchmarks.commits.each do |commit|
46
+ new_benchmarks = find_new_benchmarks(@config.benchmarks[commit], commit)
47
+ _run_benchmarks(new_benchmarks, commit) if new_benchmarks.size > 0
48
+ end
49
+ end
50
+
51
+ def _run_benchmarks(benchmarks, commit)
52
+ checkout(commit)
53
+ before
54
+ save(run(benchmarks), commit)
55
+ after
56
+ end
57
+
58
+ def find_new_benchmarks(benchmarks, commit)
59
+ new_benchmarks = []
60
+ benchmarks.each do |benchmark|
61
+ new_benchmarks << benchmark unless File.exists?(File.join(@config.output_folder, "#{commit}.#{benchmark}.json"))
62
+ end
63
+ new_benchmarks
64
+ end
65
+
66
+ def save(json, commit)
67
+ Dir.mkdir(@config.output_folder) unless Dir.exists?(@config.output_folder)
68
+ json.each do |key, value|
69
+ File.open(File.join(@config.output_folder, "#{commit}.#{key}.json"), "w") do |f|
70
+ f.write(value.to_json)
71
+ end
72
+ end
73
+ end
74
+
75
+ def list_benchmarks
76
+ benchmark_list = []
77
+ @config.benchmarks.commits.each do |commit|
78
+ commit_id = @config.benchmarks.has_tag?(commit)
79
+ commit_id = commit unless commit_id
80
+ @config.benchmarks[commit].each do |benchmark|
81
+ benchmark_list << "#{commit_id}.#{benchmark}"
82
+ end
83
+ end
84
+ benchmark_list
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,54 @@
1
+ module Mach5
2
+ module Command
3
+ module Chart
4
+ def _all_charts
5
+ @config.charts.each do |chart|
6
+ _generate_chart(chart)
7
+ end
8
+ end
9
+
10
+ def _only_charts(charts)
11
+ @config.charts.each do |chart|
12
+ if charts.include? chart.id
13
+ _generate_chart(chart)
14
+ end
15
+ end
16
+ end
17
+
18
+ def _only_new_charts
19
+ @config.charts.each do |chart|
20
+ unless File.exists?("#{File.join(@config.output_folder, chart.id)}.png")
21
+ _generate_chart(chart)
22
+ end
23
+ end
24
+ end
25
+
26
+ def _generate_chart(chart)
27
+ benchmarks = _check_benchmarks(chart)
28
+ _only_benchmarks(benchmarks) if benchmarks.size > 0
29
+ Kernel.system "phantomjs #{File.join(File.dirname(__FILE__), "../js/chart.js")} #{File.join(File.dirname(__FILE__), "../js")} \"[#{chart.build.to_json.gsub("\"", "\\\"")}]\" #{File.join(@config.output_folder, chart.id)}.png"
30
+ end
31
+
32
+ def _check_benchmarks(chart)
33
+ benchmarks = []
34
+ chart.series.each do |benchmark|
35
+ filename = _filename(benchmark[:commit_id], benchmark[:benchmark_id])
36
+ benchmarks << "#{benchmark[:commit_id]}.#{benchmark[:benchmark_id]}" unless File.exists?(filename)
37
+ end
38
+ benchmarks
39
+ end
40
+
41
+ def _filename(commit_id, benchmark_id)
42
+ if @config.benchmarks.tagged[commit_id]
43
+ "#{File.join(@config.output_folder, @config.benchmarks.tagged[commit_id])}.#{benchmark_id}.json"
44
+ else
45
+ "#{File.join(@config.output_folder, commit_id)}.#{benchmark_id}.json"
46
+ end
47
+ end
48
+
49
+ def list_charts
50
+ @config.charts.map(&:id)
51
+ end
52
+ end
53
+ end
54
+ end
@@ -2,6 +2,9 @@ require 'json'
2
2
 
3
3
  module Mach5
4
4
  class Runner
5
+ include Command::Benchmark
6
+ include Command::Chart
7
+
5
8
  def initialize(config)
6
9
  @config = config
7
10
  end
@@ -14,15 +17,6 @@ module Mach5
14
17
  end
15
18
  end
16
19
 
17
- def run(benchmarks)
18
- results = ""
19
- @config.run_commands.each do |command|
20
- output = IO.popen "#{command} --color --json run #{benchmarks.join(' ')}"
21
- results = output.readlines.join
22
- end
23
- JSON.parse(results)
24
- end
25
-
26
20
  %w{benchmark chart}.each do |method|
27
21
  define_method(method) do |options|
28
22
  if options[:all]
@@ -34,127 +28,5 @@ module Mach5
34
28
  end
35
29
  end
36
30
  end
37
-
38
- def _only_benchmarks(benchmarks)
39
- @config.benchmarks.commits.each do |commit|
40
- selected_benchmarks = _select_benchmarks(commit, @config.benchmarks.has_tag?(commit), benchmarks)
41
- _run_benchmarks(selected_benchmarks, commit) if selected_benchmarks.size > 0
42
- end
43
- end
44
-
45
- def _select_benchmarks(commit, commit_id, benchmarks)
46
- selected_benchmarks = []
47
- @config.benchmarks[commit].each do |benchmark|
48
- without_tag = "#{commit}.#{benchmark}"
49
- with_tag = "#{commit_id}.#{benchmark}"
50
- selected_benchmarks << benchmark if benchmarks.include?(without_tag)
51
- selected_benchmarks << benchmark if benchmarks.include?(with_tag) and commit_id
52
- end
53
- selected_benchmarks
54
- end
55
-
56
- def _all_benchmarks
57
- @config.benchmarks.commits.each do |commit|
58
- checkout(commit)
59
- before
60
- save(run(@config.benchmarks[commit]), commit)
61
- after
62
- end
63
- end
64
-
65
- def _only_new_benchmarks
66
- @config.benchmarks.commits.each do |commit|
67
- new_benchmarks = find_new_benchmarks(@config.benchmarks[commit], commit)
68
- _run_benchmarks(new_benchmarks, commit) if new_benchmarks.size > 0
69
- end
70
- end
71
-
72
- def _run_benchmarks(benchmarks, commit)
73
- checkout(commit)
74
- before
75
- save(run(benchmarks), commit)
76
- after
77
- end
78
-
79
- def _all_charts
80
- @config.charts.each do |chart|
81
- _generate_chart(chart)
82
- end
83
- end
84
-
85
- def _only_charts(charts)
86
- @config.charts.each do |chart|
87
- if charts.include? chart.id
88
- _generate_chart(chart)
89
- end
90
- end
91
- end
92
-
93
- def _only_new_charts
94
- @config.charts.each do |chart|
95
- unless File.exists?("#{File.join(@config.output_folder, chart.id)}.png")
96
- _generate_chart(chart)
97
- end
98
- end
99
- end
100
-
101
- def _generate_chart(chart)
102
- benchmarks = _check_benchmarks(chart)
103
- _only_benchmarks(benchmarks) if benchmarks.size > 0
104
- Kernel.system "phantomjs #{File.join(File.dirname(__FILE__), "js/chart.js")} #{File.join(File.dirname(__FILE__), "js")} \"[#{chart.build.to_json.gsub("\"", "\\\"")}]\" #{File.join(@config.output_folder, chart.id)}.png"
105
- end
106
-
107
- def _check_benchmarks(chart)
108
- benchmarks = []
109
- chart.series.each do |benchmark|
110
- filename = ""
111
- if @config.benchmarks.tagged[benchmark[:commit_id]]
112
- filename = "#{File.join(@config.output_folder, @config.benchmarks.tagged[benchmark[:commit_id]])}.#{benchmark[:benchmark_id]}.json"
113
- else
114
- filename = "#{File.join(@config.output_folder, benchmark[:commit_id])}.#{benchmark[:benchmark_id]}.json"
115
- end
116
- unless File.exists?(filename)
117
- benchmarks << "#{benchmark[:commit_id]}.#{benchmark[:benchmark_id]}"
118
- end
119
- end
120
- benchmarks
121
- end
122
-
123
- def find_new_benchmarks(benchmarks, commit)
124
- new_benchmarks = []
125
- benchmarks.each do |benchmark|
126
- new_benchmarks << benchmark unless File.exists?(File.join(@config.output_folder, "#{commit}.#{benchmark}.json"))
127
- end
128
- new_benchmarks
129
- end
130
-
131
- def save(json, commit)
132
- Dir.mkdir(@config.output_folder) unless Dir.exists?(@config.output_folder)
133
- json.each do |key, value|
134
- File.open(File.join(@config.output_folder, "#{commit}.#{key}.json"), "w") do |f|
135
- f.write(value.to_json)
136
- end
137
- end
138
- end
139
-
140
- def checkout(commit_id)
141
- Kernel.system "git checkout #{commit_id}"
142
- end
143
-
144
- def list_benchmarks
145
- benchmark_list = []
146
- @config.benchmarks.commits.each do |commit|
147
- commit_id = @config.benchmarks.has_tag?(commit)
148
- commit_id = commit unless commit_id
149
- @config.benchmarks[commit].each do |benchmark|
150
- benchmark_list << "#{commit_id}.#{benchmark}"
151
- end
152
- end
153
- benchmark_list
154
- end
155
-
156
- def list_charts
157
- @config.charts.map(&:id)
158
- end
159
31
  end
160
32
  end
@@ -0,0 +1,34 @@
1
+ # This template was generated by Mach5 Tools.
2
+ # For more information: https://github.com/igorbonadio/mach5-tools
3
+
4
+ Mach5::configure "{{PROJECT_NAME}}" do
5
+
6
+ # benchmark "8327da83b11ccfe9ab7f03426abb5b2c846e4a88" => 'your_tag' do
7
+ # add "FixtureName1.BenchmarkName1"
8
+ # add "FixtureName2.BenchmarkName2"
9
+ # end
10
+
11
+ # chart "my_chart" do
12
+ # title "My Chart"
13
+ # add_serie "8327da83b11ccfe9ab7f03426abb5b2c846e4a88" => "FixtureName1.BenchmarkName1"
14
+ # add_serie "your_tag" => "FixtureName2.BenchmarkName2"
15
+ # x_axis "Something Here"
16
+ # y_axis "Other thing here"
17
+ # end
18
+
19
+ # before do
20
+ # exec "cd build && cmake .."
21
+ # exec "cd build && make"
22
+ # end
23
+
24
+ # run do
25
+ # exec "./build/benchmark/benchmark"
26
+ # end
27
+
28
+ # after do
29
+ # exec "cd build && make clean"
30
+ # end
31
+
32
+ # output "_benchmark"
33
+
34
+ end
data/mach5-tools.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: mach5-tools 0.2.2 ruby lib
5
+ # stub: mach5-tools 0.3.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "mach5-tools"
9
- s.version = "0.2.2"
9
+ s.version = "0.3.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Igor Bonadio"]
13
- s.date = "2014-02-18"
13
+ s.date = "2014-02-19"
14
14
  s.description = "Mach 5 is a minimalist C++11 benchmarking framework."
15
15
  s.email = "igorbonadio@gmail.com"
16
16
  s.executables = ["mach5"]
@@ -33,12 +33,15 @@ Gem::Specification.new do |s|
33
33
  "lib/mach5-tools.rb",
34
34
  "lib/mach5-tools/benchmark.rb",
35
35
  "lib/mach5-tools/chart.rb",
36
+ "lib/mach5-tools/command/benchmark.rb",
37
+ "lib/mach5-tools/command/chart.rb",
36
38
  "lib/mach5-tools/config.rb",
37
39
  "lib/mach5-tools/js/chart.html",
38
40
  "lib/mach5-tools/js/chart.js",
39
41
  "lib/mach5-tools/js/highcharts.js",
40
42
  "lib/mach5-tools/js/jquery.js",
41
43
  "lib/mach5-tools/runner.rb",
44
+ "lib/templates/Mach5file",
42
45
  "mach5-tools.gemspec",
43
46
  "spec/benchmark_spec.rb",
44
47
  "spec/chart_spec.rb",
data/spec/runner_spec.rb CHANGED
@@ -141,8 +141,9 @@ module Mach5
141
141
  chart = double("Chart")
142
142
  chart.stub(:build).and_return("chart.build")
143
143
  chart.stub(:id).and_return("chart.id")
144
+ File.stub(:dirname).and_return("")
144
145
  @runner.should_receive(:_check_benchmarks).with(chart).and_return([])
145
- Kernel.should_receive(:system).with("phantomjs /Users/igorbonadio/Projetos/mach5-tools/lib/mach5-tools/js/chart.js /Users/igorbonadio/Projetos/mach5-tools/lib/mach5-tools/js \"[\\\"chart.build\\\"]\" _benchmark/chart.id.png")
146
+ Kernel.should_receive(:system).with("phantomjs /../js/chart.js /../js \"[\\\"chart.build\\\"]\" _benchmark/chart.id.png")
146
147
  @runner._generate_chart(chart)
147
148
  end
148
149
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mach5-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Bonadio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-18 00:00:00.000000000 Z
11
+ date: 2014-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -117,12 +117,15 @@ files:
117
117
  - lib/mach5-tools.rb
118
118
  - lib/mach5-tools/benchmark.rb
119
119
  - lib/mach5-tools/chart.rb
120
+ - lib/mach5-tools/command/benchmark.rb
121
+ - lib/mach5-tools/command/chart.rb
120
122
  - lib/mach5-tools/config.rb
121
123
  - lib/mach5-tools/js/chart.html
122
124
  - lib/mach5-tools/js/chart.js
123
125
  - lib/mach5-tools/js/highcharts.js
124
126
  - lib/mach5-tools/js/jquery.js
125
127
  - lib/mach5-tools/runner.rb
128
+ - lib/templates/Mach5file
126
129
  - mach5-tools.gemspec
127
130
  - spec/benchmark_spec.rb
128
131
  - spec/chart_spec.rb