mach5-tools 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +2 -0
- data/TODO +15 -0
- data/VERSION +1 -1
- data/bin/mach5 +18 -16
- data/lib/mach5-tools/benchmark.rb +34 -0
- data/lib/mach5-tools/config.rb +51 -0
- data/lib/mach5-tools/runner.rb +109 -0
- data/lib/mach5-tools.rb +3 -2
- data/mach5-tools.gemspec +75 -0
- data/spec/benchmark_spec.rb +35 -0
- data/spec/config_spec.rb +67 -0
- data/spec/runner_spec.rb +89 -0
- metadata +25 -8
- data/lib/mach5-tools/commit.rb +0 -15
- data/lib/mach5-tools/project.rb +0 -47
- data/lib/mach5.html +0 -69
- data/spec/commit_spec.rb +0 -22
- data/spec/mach5.yml +0 -19
- data/spec/project_spec.rb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 836c5778b2617e690194d748246bf9485c3afa30
|
4
|
+
data.tar.gz: 84e9ac490ec32457f6af21ad229f7753e912ce7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c663eff8d089055752384ffddb161430e8bc7e0724063e64c749998e13d27620992c0fed7dd55e142725d8c717a5178e2f5ec7167d2742599f5b511611d9b25a
|
7
|
+
data.tar.gz: 1c57a2c5ad94f77f81a46740e79461b4ec485981b7f64ca897268a254f88586dc843a2049591d6ef7b5ef72c5ed875c1999673a3a76d64e3b92c41818bb3870e
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/TODO
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
v0.1.0
|
2
|
+
[x] mach5 benchmark --list (lista e mostrar o status: se ja rodou ou nao)
|
3
|
+
[x] mach5 benchmark --only commit_id.benchmark
|
4
|
+
|
5
|
+
v0.2.0
|
6
|
+
[ ] mach5 graph
|
7
|
+
[ ] mach5 graph --all
|
8
|
+
[ ] mach5 graph --list (lista e mostrar o status: se ja existe ou nao)
|
9
|
+
[ ] mach5 graph --only graph_id
|
10
|
+
|
11
|
+
v0.3.0
|
12
|
+
[ ] mach5 init (cria o Mach5file)
|
13
|
+
[ ] mach5 generate benchmark filename benchmark1 benchmark2
|
14
|
+
[ ] mach5 generate benchmark filename benchmark1 benchmark2 --fixture fixture_name
|
15
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/bin/mach5
CHANGED
@@ -3,25 +3,27 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
3
3
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
4
|
|
5
5
|
require 'mach5-tools'
|
6
|
+
require 'thor'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
class App < Thor
|
9
|
+
desc "benchmark", "Run benchmarks"
|
10
|
+
method_option :all, :type => :boolean, :aliases => "-a", :desc => "Run all benchmarks even if there is already a result"
|
11
|
+
method_option :list, :type => :boolean, :aliases => "-l", :desc => "List all available benchmarks"
|
12
|
+
method_option :only, :type => :array, :aliases => "-o", :desc => "Run only the specified benchmarks"
|
13
|
+
def benchmark
|
14
|
+
runner = Mach5::Runner.new(eval(File.open("Mach5file").readlines.join))
|
15
|
+
if options.list
|
16
|
+
runner.list_benchmarks.each do |benchmark|
|
17
|
+
puts benchmark
|
18
|
+
end
|
19
|
+
elsif options.only
|
20
|
+
runner.benchmark(only: options.only)
|
21
|
+
else
|
22
|
+
runner.benchmark(all: options.all)
|
13
23
|
end
|
14
24
|
end
|
15
|
-
return output.to_json
|
16
|
-
end
|
17
|
-
|
18
|
-
project = Mach5Tools::Project.new(File.join(Dir.pwd, 'mach5.yml'))
|
19
|
-
mach5_data = db(project.run_all)
|
20
25
|
|
21
|
-
|
22
|
-
file.write("var mach5 = {};\nmach5[\"data\"] = #{mach5_data.to_s}")
|
26
|
+
default_task :benchmark
|
23
27
|
end
|
24
28
|
|
25
|
-
|
26
|
-
file.write(File.open(File.join(File.dirname(__FILE__), '..', 'lib', 'mach5.html')).readlines.join)
|
27
|
-
end
|
29
|
+
App.start
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Mach5
|
2
|
+
class Benchmark
|
3
|
+
def initialize(memory, tags)
|
4
|
+
@memory = memory
|
5
|
+
@tags = tags
|
6
|
+
end
|
7
|
+
|
8
|
+
def [](commit_id)
|
9
|
+
benchmarks = @memory[commit_id]
|
10
|
+
if benchmarks
|
11
|
+
benchmarks
|
12
|
+
else
|
13
|
+
@memory[@tags[commit_id]]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def add(commit_id, value)
|
18
|
+
@memory[commit_id] ||= []
|
19
|
+
@memory[commit_id] << value
|
20
|
+
end
|
21
|
+
|
22
|
+
def tag(commit_id, tag_name)
|
23
|
+
@tags[tag_name] = commit_id
|
24
|
+
end
|
25
|
+
|
26
|
+
def commits
|
27
|
+
@memory.keys
|
28
|
+
end
|
29
|
+
|
30
|
+
def has_tag?(commit_id)
|
31
|
+
@tags.invert[commit_id]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Mach5
|
2
|
+
def self.configure(project_name, &block)
|
3
|
+
Config.new(project_name, block)
|
4
|
+
end
|
5
|
+
|
6
|
+
class Config
|
7
|
+
attr_accessor :before_commands
|
8
|
+
attr_accessor :run_commands
|
9
|
+
attr_accessor :after_commands
|
10
|
+
attr_accessor :project_name
|
11
|
+
attr_accessor :output_folder
|
12
|
+
attr_accessor :benchmarks
|
13
|
+
|
14
|
+
def initialize(project_name, block)
|
15
|
+
@project_name = project_name
|
16
|
+
@benchmarks = Benchmark.new(Hash.new, Hash.new)
|
17
|
+
instance_eval(&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
%w{before run after}.each do |method|
|
21
|
+
define_method(method) do |&block|
|
22
|
+
instance_variable_set("@commands", [])
|
23
|
+
instance_eval(&block)
|
24
|
+
instance_variable_set("@#{method}_commands", instance_variable_get("@commands"))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def benchmark(commit_id, &block)
|
29
|
+
if commit_id.is_a? Hash
|
30
|
+
@commit_id = commit_id.keys[0]
|
31
|
+
@benchmarks.tag(@commit_id, commit_id.values[0])
|
32
|
+
else
|
33
|
+
@commit_id = commit_id
|
34
|
+
end
|
35
|
+
instance_eval(&block)
|
36
|
+
@commit_id = ""
|
37
|
+
end
|
38
|
+
|
39
|
+
def output(folder)
|
40
|
+
@output_folder = folder
|
41
|
+
end
|
42
|
+
|
43
|
+
def add(benchmark)
|
44
|
+
@benchmarks.add(@commit_id, benchmark)
|
45
|
+
end
|
46
|
+
|
47
|
+
def exec(command)
|
48
|
+
@commands << command
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Mach5
|
4
|
+
class Runner
|
5
|
+
def initialize(config)
|
6
|
+
@config = config
|
7
|
+
end
|
8
|
+
|
9
|
+
%w{before after}.each do |method|
|
10
|
+
define_method(method) do
|
11
|
+
@config.send("#{method}_commands").each do |command|
|
12
|
+
Kernel.system command
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
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
|
+
def benchmark(options)
|
27
|
+
if options[:all]
|
28
|
+
run_all_benchmarks
|
29
|
+
elsif options[:only]
|
30
|
+
run_only(options[:only])
|
31
|
+
else
|
32
|
+
run_only_new_benchmarks
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def run_only(benchmarks)
|
37
|
+
@config.benchmarks.commits.each do |commit|
|
38
|
+
commit_id = @config.benchmarks.has_tag?(commit)
|
39
|
+
selected_benchmarks = []
|
40
|
+
@config.benchmarks[commit].each do |benchmark|
|
41
|
+
without_tag = "#{commit}.#{benchmark}"
|
42
|
+
with_tag = "#{commit_id}.#{benchmark}"
|
43
|
+
selected_benchmarks << benchmark if benchmarks.include?(without_tag)
|
44
|
+
selected_benchmarks << benchmark if benchmarks.include?(with_tag) and commit_id
|
45
|
+
end
|
46
|
+
if selected_benchmarks.size > 0
|
47
|
+
checkout(commit)
|
48
|
+
before
|
49
|
+
save(run(selected_benchmarks), commit)
|
50
|
+
after
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def run_all_benchmarks
|
56
|
+
@config.benchmarks.commits.each do |commit|
|
57
|
+
checkout(commit)
|
58
|
+
before
|
59
|
+
save(run(@config.benchmarks[commit]), commit)
|
60
|
+
after
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def run_only_new_benchmarks
|
65
|
+
@config.benchmarks.commits.each do |commit|
|
66
|
+
new_benchmarks = find_new_benchmarks(@config.benchmarks[commit], commit)
|
67
|
+
if new_benchmarks.size > 0
|
68
|
+
checkout(commit)
|
69
|
+
before
|
70
|
+
save(run(new_benchmarks), commit)
|
71
|
+
after
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def find_new_benchmarks(benchmarks, commit)
|
77
|
+
new_benchmarks = []
|
78
|
+
benchmarks.each do |benchmark|
|
79
|
+
new_benchmarks << benchmark unless File.exists?(File.join(@config.output_folder, "#{commit}.#{benchmark}.json"))
|
80
|
+
end
|
81
|
+
new_benchmarks
|
82
|
+
end
|
83
|
+
|
84
|
+
def save(json, commit)
|
85
|
+
Dir.mkdir(@config.output_folder) unless Dir.exists?(@config.output_folder)
|
86
|
+
json.each do |key, value|
|
87
|
+
File.open(File.join(@config.output_folder, "#{commit}.#{key}.json"), "w") do |f|
|
88
|
+
f.write(value.to_json)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
def checkout(commit_id)
|
94
|
+
Kernel.system "git checkout #{commit_id}"
|
95
|
+
end
|
96
|
+
|
97
|
+
def list_benchmarks
|
98
|
+
benchmark_list = []
|
99
|
+
@config.benchmarks.commits.each do |commit|
|
100
|
+
commit_id = @config.benchmarks.has_tag?(commit)
|
101
|
+
commit_id = commit unless commit_id
|
102
|
+
@config.benchmarks[commit].each do |benchmark|
|
103
|
+
benchmark_list << "#{commit_id}.#{benchmark}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
benchmark_list
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/lib/mach5-tools.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
root_path = File.expand_path(File.dirname(__FILE__))
|
2
2
|
|
3
|
-
require File.join(root_path, 'mach5-tools/
|
4
|
-
require File.join(root_path, 'mach5-tools/
|
3
|
+
require File.join(root_path, 'mach5-tools/benchmark')
|
4
|
+
require File.join(root_path, 'mach5-tools/config')
|
5
|
+
require File.join(root_path, 'mach5-tools/runner')
|
data/mach5-tools.gemspec
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: mach5-tools 0.1.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "mach5-tools"
|
9
|
+
s.version = "0.1.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.authors = ["Igor Bonadio"]
|
13
|
+
s.date = "2014-02-10"
|
14
|
+
s.description = "Mach 5 is a minimalist C++11 benchmarking framework."
|
15
|
+
s.email = "igorbonadio@gmail.com"
|
16
|
+
s.executables = ["mach5"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc",
|
20
|
+
"TODO"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".document",
|
24
|
+
".rspec",
|
25
|
+
"Gemfile",
|
26
|
+
"Gemfile.lock",
|
27
|
+
"LICENSE.txt",
|
28
|
+
"README.rdoc",
|
29
|
+
"Rakefile",
|
30
|
+
"VERSION",
|
31
|
+
"bin/mach5",
|
32
|
+
"lib/mach5-tools.rb",
|
33
|
+
"lib/mach5-tools/benchmark.rb",
|
34
|
+
"lib/mach5-tools/config.rb",
|
35
|
+
"lib/mach5-tools/runner.rb",
|
36
|
+
"mach5-tools.gemspec",
|
37
|
+
"spec/benchmark_spec.rb",
|
38
|
+
"spec/config_spec.rb",
|
39
|
+
"spec/runner_spec.rb",
|
40
|
+
"spec/spec_helper.rb"
|
41
|
+
]
|
42
|
+
s.homepage = "http://github.com/igorbonadio/mach5-tools"
|
43
|
+
s.licenses = ["MIT"]
|
44
|
+
s.require_paths = ["lib"]
|
45
|
+
s.rubygems_version = "2.1.11"
|
46
|
+
s.summary = "Minimalist C++11 benchmarking framework."
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
s.specification_version = 4
|
50
|
+
|
51
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
+
s.add_runtime_dependency(%q<thor>, ["~> 0.18.1"])
|
53
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
54
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
55
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
56
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0.0"])
|
57
|
+
s.add_development_dependency(%q<simplecov>, ["~> 0.8.2"])
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<thor>, ["~> 0.18.1"])
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
61
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
|
64
|
+
s.add_dependency(%q<simplecov>, ["~> 0.8.2"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<thor>, ["~> 0.18.1"])
|
68
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
69
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
71
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0.0"])
|
72
|
+
s.add_dependency(%q<simplecov>, ["~> 0.8.2"])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module Mach5
|
4
|
+
describe Benchmark do
|
5
|
+
before(:each) do
|
6
|
+
@memory = double('Memory')
|
7
|
+
@tags = double('Tags')
|
8
|
+
@benchmark = Benchmark.new(@memory, @tags)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should find benchmarks by commit id" do
|
12
|
+
@memory.should_receive("[]").with("ab7c4351a13b29ea4c21e3662f9f567ff19a854d").and_return(["HMMDishonestCasino.Evaluate", "HMMDishonestCasino.Viterbi"])
|
13
|
+
@benchmark["ab7c4351a13b29ea4c21e3662f9f567ff19a854d"]
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should find benchmarks by tag" do
|
17
|
+
@memory.should_receive("[]").with("v1.0.1").and_return(nil)
|
18
|
+
@tags.should_receive("[]").with("v1.0.1").and_return("ab7c4351a13b29ea4c21e3662f9f567ff19a854d")
|
19
|
+
@memory.should_receive("[]").with("ab7c4351a13b29ea4c21e3662f9f567ff19a854d")
|
20
|
+
@benchmark["v1.0.1"]
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should add benchmarks by commit id" do
|
24
|
+
commit_list = double("CommitList")
|
25
|
+
commit_list.should_receive("<<").with("HMMDishonestCasino.Evaluate")
|
26
|
+
@memory.stub("[]").and_return(commit_list)
|
27
|
+
@benchmark.add('ab7c4351a13b29ea4c21e3662f9f567ff19a854d', "HMMDishonestCasino.Evaluate")
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should tag commits" do
|
31
|
+
@tags.should_receive("[]=").with("v1.0.1", "ab7c4351a13b29ea4c21e3662f9f567ff19a854d")
|
32
|
+
@benchmark.tag("ab7c4351a13b29ea4c21e3662f9f567ff19a854d", "v1.0.1")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module Mach5
|
4
|
+
describe "Config" do
|
5
|
+
it "should receive a block" do
|
6
|
+
object = double("Object")
|
7
|
+
object.should_receive(:touch)
|
8
|
+
Mach5::configure("MyProject") do
|
9
|
+
object.touch
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create a list of before commands" do
|
14
|
+
config = Mach5::configure("MyProject") do
|
15
|
+
before do
|
16
|
+
exec "cd build && cmake .."
|
17
|
+
exec "cd build && make"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
config.before_commands.should be == ["cd build && cmake ..", "cd build && make"]
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should create a list of run commands" do
|
24
|
+
config = Mach5::configure("MyProject") do
|
25
|
+
run do
|
26
|
+
exec "./build/benchmark/benchmark"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
config.run_commands.should be == ["./build/benchmark/benchmark"]
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should create a list of after commands" do
|
33
|
+
config = Mach5::configure("MyProject") do
|
34
|
+
after do
|
35
|
+
exec "cd build && make clean"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
config.after_commands.should be == ["cd build && make clean"]
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should define benchmarks" do
|
42
|
+
Benchmark.any_instance.should_receive(:add).with("c031c8e9afe1493a81274adbdb61b81bc30ef522", "HMMDishonestCasino.Evaluate")
|
43
|
+
Mach5::configure("MyProject") do
|
44
|
+
benchmark "c031c8e9afe1493a81274adbdb61b81bc30ef522" do
|
45
|
+
add "HMMDishonestCasino.Evaluate"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should define benchmarks with tags of commits" do
|
51
|
+
Benchmark.any_instance.should_receive(:add).with("c031c8e9afe1493a81274adbdb61b81bc30ef522", "HMMDishonestCasino.Evaluate")
|
52
|
+
Benchmark.any_instance.should_receive(:tag).with("c031c8e9afe1493a81274adbdb61b81bc30ef522", "MyProject")
|
53
|
+
Mach5::configure("MyProject") do
|
54
|
+
benchmark "c031c8e9afe1493a81274adbdb61b81bc30ef522" => "MyProject" do
|
55
|
+
add "HMMDishonestCasino.Evaluate"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should define the output folder" do
|
61
|
+
config = Mach5::configure("MyProject") do
|
62
|
+
output "_benchmark"
|
63
|
+
end
|
64
|
+
config.output_folder.should be == "_benchmark"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/spec/runner_spec.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module Mach5
|
4
|
+
describe Runner do
|
5
|
+
before(:each) do
|
6
|
+
Dir.stub(:mkdir)
|
7
|
+
@config = Mach5::configure "ToPS::Core" do
|
8
|
+
benchmark "ab7c4351a13b29ea4c21e3662f9f567ff19a854d" => 'v1.0.0' do
|
9
|
+
add "DishonestCasinoHMM.Evaluate"
|
10
|
+
add "DishonestCasinoHMM.Viterbi"
|
11
|
+
end
|
12
|
+
|
13
|
+
benchmark "c031c8e9afe1493a81274adbdb61b81bc30ef522" do
|
14
|
+
add "DishonestCasinoHMM.Forward"
|
15
|
+
add "DishonestCasinoHMM.Backward"
|
16
|
+
add "DishonestCasinoHMM.PosteriorDecoding"
|
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
|
35
|
+
|
36
|
+
@runner = Runner.new(@config)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should run before commands" do
|
40
|
+
Kernel.should_receive(:system).with("cd build && cmake ..")
|
41
|
+
Kernel.should_receive(:system).with("cd build && make")
|
42
|
+
@runner.before
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should run after commands" do
|
46
|
+
Kernel.should_receive(:system).with("cd build && make clean")
|
47
|
+
@runner.after
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should run benchmark" do
|
51
|
+
stdio = double("STDIO")
|
52
|
+
stdio.should_receive(:readlines).and_return(["{}"])
|
53
|
+
IO.should_receive(:popen).with("./build/benchmark/benchmark --color --json run HMM.Evaluate HMM.Viterbi").and_return(stdio)
|
54
|
+
@runner.run(["HMM.Evaluate", "HMM.Viterbi"])
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should save results" do
|
58
|
+
Dir.should_receive(:exists?).and_return(false)
|
59
|
+
Dir.should_receive(:mkdir)
|
60
|
+
File.should_receive(:open).with("#{@config.output_folder}/commit.key.json", "w")
|
61
|
+
@runner.save({"key" => "value"}, "commit")
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should run all benchmarks" do
|
65
|
+
Kernel.should_receive(:system).with("git checkout ab7c4351a13b29ea4c21e3662f9f567ff19a854d")
|
66
|
+
@runner.should_receive(:before)
|
67
|
+
@runner.should_receive(:run).with(["DishonestCasinoHMM.Evaluate", "DishonestCasinoHMM.Viterbi"]).and_return({})
|
68
|
+
@runner.should_receive(:after)
|
69
|
+
Kernel.should_receive(:system).with("git checkout c031c8e9afe1493a81274adbdb61b81bc30ef522")
|
70
|
+
@runner.should_receive(:before)
|
71
|
+
@runner.should_receive(:run).with(["DishonestCasinoHMM.Forward", "DishonestCasinoHMM.Backward", "DishonestCasinoHMM.PosteriorDecoding"]).and_return({})
|
72
|
+
@runner.should_receive(:after)
|
73
|
+
@runner.benchmark({all: true})
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should run only new benchmarks" do
|
77
|
+
File.should_receive(:exists?).with("_benchmark/ab7c4351a13b29ea4c21e3662f9f567ff19a854d.DishonestCasinoHMM.Evaluate.json").and_return(true)
|
78
|
+
File.should_receive(:exists?).with("_benchmark/ab7c4351a13b29ea4c21e3662f9f567ff19a854d.DishonestCasinoHMM.Viterbi.json").and_return(true)
|
79
|
+
File.should_receive(:exists?).with("_benchmark/c031c8e9afe1493a81274adbdb61b81bc30ef522.DishonestCasinoHMM.Forward.json").and_return(true)
|
80
|
+
File.should_receive(:exists?).with("_benchmark/c031c8e9afe1493a81274adbdb61b81bc30ef522.DishonestCasinoHMM.Backward.json").and_return(false)
|
81
|
+
File.should_receive(:exists?).with("_benchmark/c031c8e9afe1493a81274adbdb61b81bc30ef522.DishonestCasinoHMM.PosteriorDecoding.json").and_return(false)
|
82
|
+
Kernel.should_receive(:system).with("git checkout c031c8e9afe1493a81274adbdb61b81bc30ef522")
|
83
|
+
@runner.should_receive(:before)
|
84
|
+
@runner.should_receive(:run).with(["DishonestCasinoHMM.Backward", "DishonestCasinoHMM.PosteriorDecoding"]).and_return({})
|
85
|
+
@runner.should_receive(:after)
|
86
|
+
@runner.benchmark({})
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mach5-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.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-
|
11
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.18.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.18.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -88,6 +102,7 @@ extensions: []
|
|
88
102
|
extra_rdoc_files:
|
89
103
|
- LICENSE.txt
|
90
104
|
- README.rdoc
|
105
|
+
- TODO
|
91
106
|
files:
|
92
107
|
- .document
|
93
108
|
- .rspec
|
@@ -99,13 +114,15 @@ files:
|
|
99
114
|
- VERSION
|
100
115
|
- bin/mach5
|
101
116
|
- lib/mach5-tools.rb
|
102
|
-
- lib/mach5-tools/
|
103
|
-
- lib/mach5-tools/
|
104
|
-
- lib/mach5.
|
105
|
-
-
|
106
|
-
- spec/
|
107
|
-
- spec/
|
117
|
+
- lib/mach5-tools/benchmark.rb
|
118
|
+
- lib/mach5-tools/config.rb
|
119
|
+
- lib/mach5-tools/runner.rb
|
120
|
+
- mach5-tools.gemspec
|
121
|
+
- spec/benchmark_spec.rb
|
122
|
+
- spec/config_spec.rb
|
123
|
+
- spec/runner_spec.rb
|
108
124
|
- spec/spec_helper.rb
|
125
|
+
- TODO
|
109
126
|
homepage: http://github.com/igorbonadio/mach5-tools
|
110
127
|
licenses:
|
111
128
|
- MIT
|
data/lib/mach5-tools/commit.rb
DELETED
data/lib/mach5-tools/project.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
module Mach5Tools
|
5
|
-
class Project
|
6
|
-
def initialize(filename)
|
7
|
-
@yaml = YAML.load_file(filename)
|
8
|
-
end
|
9
|
-
|
10
|
-
def commits
|
11
|
-
_commits = []
|
12
|
-
@yaml["benchmarks"].each do |commit, benchmarks|
|
13
|
-
_commits << Commit.new(commit, benchmarks)
|
14
|
-
end
|
15
|
-
return _commits
|
16
|
-
end
|
17
|
-
|
18
|
-
%w{before after}.each do |method|
|
19
|
-
define_method(method) do
|
20
|
-
@yaml[method].each do |cmd|
|
21
|
-
Kernel.system cmd
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def run(benchmarks)
|
27
|
-
results = ""
|
28
|
-
@yaml["run"].each do |cmd|
|
29
|
-
output = IO.popen "#{cmd} run #{benchmarks.join(" ")}"
|
30
|
-
results = output.readlines.join
|
31
|
-
end
|
32
|
-
JSON.parse(results)
|
33
|
-
end
|
34
|
-
|
35
|
-
def run_all
|
36
|
-
results = {}
|
37
|
-
commits.each do |commit|
|
38
|
-
commit.checkout
|
39
|
-
before
|
40
|
-
results[commit.id] = run(commit.benchmarks)
|
41
|
-
after
|
42
|
-
end
|
43
|
-
results
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
data/lib/mach5.html
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Mach5</title>
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
|
7
|
-
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
|
8
|
-
<!--[if lt IE 9]>
|
9
|
-
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
10
|
-
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
|
11
|
-
<![endif]-->
|
12
|
-
</head>
|
13
|
-
<body>
|
14
|
-
<div id="container" style="width:100%; height:100%;"></div>
|
15
|
-
|
16
|
-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
|
17
|
-
<script src="http://code.highcharts.com/highcharts.js"></script>
|
18
|
-
<script src="mach5.js"></script>
|
19
|
-
<script>
|
20
|
-
$(function () {
|
21
|
-
var index_size = 0;
|
22
|
-
var data = []
|
23
|
-
for (var algorithm in mach5['data']) {
|
24
|
-
for (var benchmark in mach5['data'][algorithm]) {
|
25
|
-
index_size = mach5['data'][algorithm][benchmark].length;
|
26
|
-
var data_data = []
|
27
|
-
for (var i = 0; i < index_size; i++) {
|
28
|
-
data_data.push(mach5['data'][algorithm][benchmark][i]['duration']);
|
29
|
-
}
|
30
|
-
data.push({
|
31
|
-
name: algorithm + "#" + benchmark,
|
32
|
-
data: data_data
|
33
|
-
});
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
$('#container').height($(document).height());
|
38
|
-
|
39
|
-
var index = Array.apply(null, Array(index_size)).map(function (_, i) {return i;});
|
40
|
-
|
41
|
-
$('#container').highcharts({
|
42
|
-
chart: {
|
43
|
-
type: 'line'
|
44
|
-
},
|
45
|
-
title: {
|
46
|
-
text: 'Benchmark'
|
47
|
-
},
|
48
|
-
xAxis: {
|
49
|
-
categories: index,
|
50
|
-
title: {
|
51
|
-
text: 'Index'
|
52
|
-
}
|
53
|
-
},
|
54
|
-
yAxis: {
|
55
|
-
title: {
|
56
|
-
text: 'Time (s)'
|
57
|
-
}
|
58
|
-
},
|
59
|
-
series: data
|
60
|
-
});
|
61
|
-
|
62
|
-
$(window).resize(function() {
|
63
|
-
console.log($(window).height());
|
64
|
-
$('#container').height($(window).height());
|
65
|
-
});
|
66
|
-
});
|
67
|
-
</script>
|
68
|
-
</body>
|
69
|
-
</html>
|
data/spec/commit_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
module Mach5Tools
|
4
|
-
describe Commit do
|
5
|
-
before(:each) do
|
6
|
-
@commit = Commit.new("ab7c4351a13b29ea4c21e3662f9f567ff19a854d", YAML.load_file(File.expand_path(File.dirname(__FILE__) + '/mach5.yml'))["benchmarks"]["ab7c4351a13b29ea4c21e3662f9f567ff19a854d"])
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should have a identifier" do
|
10
|
-
@commit.id.should be == "ab7c4351a13b29ea4c21e3662f9f567ff19a854d"
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should have a list of benchmarks" do
|
14
|
-
@commit.benchmarks.size.should be == 5
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should checkout a specific commit" do
|
18
|
-
Kernel.should_receive(:system).with("git checkout ab7c4351a13b29ea4c21e3662f9f567ff19a854d")
|
19
|
-
@commit.checkout
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/spec/mach5.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
benchmarks:
|
2
|
-
ab7c4351a13b29ea4c21e3662f9f567ff19a854d:
|
3
|
-
- AHiddenMarkovModelEvaluatesSequences
|
4
|
-
- AHiddenMarkovModelFindsTheBestPath
|
5
|
-
- AHiddenMarkovModelCalculatesProbabilityOfObservationsUsingForward
|
6
|
-
- AHiddenMarkovModelCalculatesProbabilityOfObservationsUsingBackward
|
7
|
-
- AHiddenMarkovModelDecodesASequenceOfObservationsUsingThePosteriorProbability
|
8
|
-
c031c8e9afe1493a81274adbdb61b81bc30ef522:
|
9
|
-
- ALinearChainCRFFindsTheBestPath
|
10
|
-
- ALinearChainCRFCalculatesProbabilityOfObservationsUsingForward
|
11
|
-
- ALinearChainCRFCalculatesProbabilityOfObservationsUsingBackward
|
12
|
-
- ALinearChainCRFDecodesASequenceOfObservationsUsingThePosteriorProbability
|
13
|
-
before:
|
14
|
-
- cd build && cmake ..
|
15
|
-
- cd build && make
|
16
|
-
run:
|
17
|
-
- ./build/benchmark/benchmark
|
18
|
-
after:
|
19
|
-
- cd build && make clean
|
data/spec/project_spec.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
module Mach5Tools
|
4
|
-
describe Project do
|
5
|
-
before(:each) do
|
6
|
-
@project = Project.new(File.expand_path(File.dirname(__FILE__) + '/mach5.yml'))
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should be created by a YAML file" do
|
10
|
-
@project.should_not be_nil
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should have a list of commands to execute before benchmarks" do
|
14
|
-
Kernel.should_receive(:system).with("cd build && cmake ..")
|
15
|
-
Kernel.should_receive(:system).with("cd build && make")
|
16
|
-
@project.before
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should have a list of commands to execute benchmarks" do
|
20
|
-
output = double("Output")
|
21
|
-
output.stub(:readlines).and_return(["{\"output\": 1}"])
|
22
|
-
IO.should_receive(:popen).with("./build/benchmark/benchmark run test1 test2").and_return(output)
|
23
|
-
@project.run(["test1", "test2"])
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should have a list of commands to execute after benchmarks" do
|
27
|
-
Kernel.should_receive(:system).with("cd build && make clean")
|
28
|
-
@project.after
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should have a list of commits" do
|
32
|
-
@project.commits.size.should be == 2
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should run all benchmarks" do
|
36
|
-
Kernel.should_receive(:system).with("git checkout ab7c4351a13b29ea4c21e3662f9f567ff19a854d")
|
37
|
-
Kernel.should_receive(:system).with("cd build && cmake ..")
|
38
|
-
Kernel.should_receive(:system).with("cd build && make")
|
39
|
-
output = double("Output")
|
40
|
-
output.stub(:readlines).and_return(["{\"output\": 1}"])
|
41
|
-
IO.should_receive(:popen).with("./build/benchmark/benchmark run AHiddenMarkovModelEvaluatesSequences AHiddenMarkovModelFindsTheBestPath AHiddenMarkovModelCalculatesProbabilityOfObservationsUsingForward AHiddenMarkovModelCalculatesProbabilityOfObservationsUsingBackward AHiddenMarkovModelDecodesASequenceOfObservationsUsingThePosteriorProbability").and_return(output)
|
42
|
-
Kernel.should_receive(:system).with("cd build && make clean")
|
43
|
-
|
44
|
-
Kernel.should_receive(:system).with("git checkout c031c8e9afe1493a81274adbdb61b81bc30ef522")
|
45
|
-
Kernel.should_receive(:system).with("cd build && cmake ..")
|
46
|
-
Kernel.should_receive(:system).with("cd build && make")
|
47
|
-
output = double("Output")
|
48
|
-
output.stub(:readlines).and_return(["{\"output\": 1}"])
|
49
|
-
IO.should_receive(:popen).with("./build/benchmark/benchmark run ALinearChainCRFFindsTheBestPath ALinearChainCRFCalculatesProbabilityOfObservationsUsingForward ALinearChainCRFCalculatesProbabilityOfObservationsUsingBackward ALinearChainCRFDecodesASequenceOfObservationsUsingThePosteriorProbability").and_return(output)
|
50
|
-
Kernel.should_receive(:system).with("cd build && make clean")
|
51
|
-
|
52
|
-
@project.run_all
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|