jsl-git-branch-benchmark 0.2
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.
- data/README.markdown +49 -0
- data/Rakefile +0 -0
- data/bin/gbb +45 -0
- data/git-branch-benchmark.gemspec +21 -0
- data/lib/git_branch_benchmark.rb +66 -0
- metadata +74 -0
data/README.markdown
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
GitBranchBenchmark
|
2
|
+
==================
|
3
|
+
|
4
|
+
GitBranchBenchmark is used for testing the performance of code in two different
|
5
|
+
branches. Currently it is only able to be used to compare the execution time
|
6
|
+
of different branches by requesting a URL on each.
|
7
|
+
|
8
|
+
Project Status
|
9
|
+
--------------
|
10
|
+
|
11
|
+
This is really just quick prototype code to be expanded later, though it may
|
12
|
+
be useful in its current state. Libraries and command-line options may change
|
13
|
+
in the near future.
|
14
|
+
|
15
|
+
Installation
|
16
|
+
------------
|
17
|
+
|
18
|
+
sudo gem install git-branch-benchmark
|
19
|
+
|
20
|
+
Usage Examples
|
21
|
+
--------------
|
22
|
+
|
23
|
+
|
24
|
+
1. gbb -b test2 -u http://localhost:3000/test -u http://localhost:3000/test2
|
25
|
+
|
26
|
+
tests the current branch against branch 'test2' and outputs average times for
|
27
|
+
both tests.
|
28
|
+
|
29
|
+
2. gbb -b test1 -b test2 -u http://localhost:3000/test
|
30
|
+
|
31
|
+
tests the url given in branch 'test1' and 'test2', outputting the average times
|
32
|
+
for execution in both branches
|
33
|
+
|
34
|
+
Notes
|
35
|
+
-----
|
36
|
+
|
37
|
+
If one branch is given on the command line, gbb assumes that is the 'other' branch,
|
38
|
+
and that the current branch should also be tested. If two branch options are given,
|
39
|
+
the current branch isn't added to the list of branches to test.
|
40
|
+
|
41
|
+
Todo
|
42
|
+
----
|
43
|
+
|
44
|
+
1. The GitBranchBenchmark library should be a thin wrapper over the stdlib 'benchmark'
|
45
|
+
suite, enabling it to compare the execution of blocks of code in different git
|
46
|
+
branches.
|
47
|
+
|
48
|
+
2. Add specs
|
49
|
+
|
data/Rakefile
ADDED
File without changes
|
data/bin/gbb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'getoptlong'
|
4
|
+
require 'rdoc/usage'
|
5
|
+
require File.join(File.dirname(__FILE__), %w{.. lib git_branch_benchmark})
|
6
|
+
|
7
|
+
def parse_options
|
8
|
+
|
9
|
+
opts = GetoptLong.new(
|
10
|
+
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
11
|
+
[ '--branch', '-b', GetoptLong::REQUIRED_ARGUMENT ],
|
12
|
+
[ '--url', '-u', GetoptLong::REQUIRED_ARGUMENT ],
|
13
|
+
[ '--verbose', '-v', GetoptLong::OPTIONAL_ARGUMENT ]
|
14
|
+
)
|
15
|
+
|
16
|
+
branches = []
|
17
|
+
urls = []
|
18
|
+
verbosity = 0
|
19
|
+
|
20
|
+
opts.each do |opt, arg|
|
21
|
+
case opt
|
22
|
+
when '--branch'
|
23
|
+
branches << arg
|
24
|
+
when '--url'
|
25
|
+
urls << arg
|
26
|
+
when '--verbose'
|
27
|
+
verbosity += 1
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
raise ArgumentError, "We need some urls to benchmark" unless urls.size >= 1
|
32
|
+
|
33
|
+
[ branches, urls, verbosity ]
|
34
|
+
end
|
35
|
+
|
36
|
+
def main
|
37
|
+
branches, urls, verbosity = parse_options
|
38
|
+
gbb = GitBranchBenchmark.new
|
39
|
+
gbb.branches = branches
|
40
|
+
gbb.urls = urls
|
41
|
+
gbb.verbosity = verbosity
|
42
|
+
gbb.run!
|
43
|
+
end
|
44
|
+
|
45
|
+
main
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "git-branch-benchmark"
|
3
|
+
s.version = "0.2"
|
4
|
+
s.date = "2009-01-19"
|
5
|
+
s.summary = "Tool for git branch benchmarking"
|
6
|
+
s.email = "justin@phq.org"
|
7
|
+
s.homepage = "http://github.com/jsl/git-branch-benchmark"
|
8
|
+
s.description = "GitBrachBenchMark is a tool for testing performance of code in different git branches."
|
9
|
+
s.has_rdoc = true
|
10
|
+
s.authors = ["Justin Leitgeb"]
|
11
|
+
s.files = ["Rakefile",
|
12
|
+
"lib/git_branch_benchmark.rb",
|
13
|
+
"README.markdown",
|
14
|
+
"bin/gbb",
|
15
|
+
"git-branch-benchmark.gemspec"]
|
16
|
+
s.test_files = [ ]
|
17
|
+
s.rdoc_options = ["--main"]
|
18
|
+
s.executables = 'gbb'
|
19
|
+
s.add_dependency("git", ["> 0.0.0"])
|
20
|
+
s.add_dependency("curb", ["> 0.0.0"])
|
21
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'curb'
|
3
|
+
require 'git'
|
4
|
+
require 'benchmark'
|
5
|
+
|
6
|
+
class GitBranchBenchmark
|
7
|
+
VERSION = 0.1
|
8
|
+
|
9
|
+
attr_accessor :urls, :branches, :verbosity
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@branches = []
|
13
|
+
@urls = []
|
14
|
+
@verbosity = 0
|
15
|
+
|
16
|
+
@git = Git.open('.')
|
17
|
+
@original_branch = @git.branch.name
|
18
|
+
end
|
19
|
+
|
20
|
+
# When called with a block, runs the block code in each branch given. If
|
21
|
+
# we were only initialized with one branch, adds the current branch to the
|
22
|
+
# list of branches to test against. Restores state by checking out original
|
23
|
+
# branch after execution, and returns hash of time results on each branch.
|
24
|
+
def branch_realtime_measure
|
25
|
+
times = {}
|
26
|
+
|
27
|
+
@branches.each do |branch|
|
28
|
+
@git.checkout(branch)
|
29
|
+
times[branch] = Benchmark.realtime { yield }
|
30
|
+
puts "Operation on #{branch} took #{times[branch]} seconds." if @verbosity >= 1
|
31
|
+
end
|
32
|
+
|
33
|
+
@git.checkout(@original_branch)
|
34
|
+
|
35
|
+
times
|
36
|
+
end
|
37
|
+
|
38
|
+
def run!
|
39
|
+
@branches << @original_branch unless @branches.size >= 2
|
40
|
+
|
41
|
+
results = @branches.inject({}) {|result, element| result.merge({ element => [] })}
|
42
|
+
|
43
|
+
@urls.each do |url|
|
44
|
+
|
45
|
+
branch_realtime_measure { Curl::Easy.perform(url) }.each_pair do |k, v|
|
46
|
+
results[k] << v
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
print_stats(results)
|
51
|
+
end
|
52
|
+
|
53
|
+
def avg(ary)
|
54
|
+
sum = eval ary.join('+')
|
55
|
+
sum.to_f / ary.size
|
56
|
+
end
|
57
|
+
|
58
|
+
# Prints stats from results in input hash
|
59
|
+
def print_stats(times)
|
60
|
+
puts "Results are for test with #{@urls.size} urls.\n\n"
|
61
|
+
|
62
|
+
@branches.each do |b|
|
63
|
+
puts "Avg execution time for branch #{b}: #{avg(times[b])}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jsl-git-branch-benchmark
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.2"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Leitgeb
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-19 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: git
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.0.0
|
23
|
+
version:
|
24
|
+
- !ruby/object:Gem::Dependency
|
25
|
+
name: curb
|
26
|
+
version_requirement:
|
27
|
+
version_requirements: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">"
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: 0.0.0
|
32
|
+
version:
|
33
|
+
description: GitBrachBenchMark is a tool for testing performance of code in different git branches.
|
34
|
+
email: justin@phq.org
|
35
|
+
executables:
|
36
|
+
- gbb
|
37
|
+
extensions: []
|
38
|
+
|
39
|
+
extra_rdoc_files: []
|
40
|
+
|
41
|
+
files:
|
42
|
+
- Rakefile
|
43
|
+
- lib/git_branch_benchmark.rb
|
44
|
+
- README.markdown
|
45
|
+
- bin/gbb
|
46
|
+
- git-branch-benchmark.gemspec
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://github.com/jsl/git-branch-benchmark
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options:
|
51
|
+
- --main
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.2.0
|
70
|
+
signing_key:
|
71
|
+
specification_version: 2
|
72
|
+
summary: Tool for git branch benchmarking
|
73
|
+
test_files: []
|
74
|
+
|