summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-17 08:22:49 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-17 08:22:49 -0800
commitb0d47b3112b00cb6c1ae72d6d8a43e583af117ea (patch)
tree5d8094a62450a88ccc542a7a19e724004fdb8ca8
parentba0f3cc565d051e79db634dbff1f1d4c71291461 (diff)
downloadthird_party-ruby-git-b0d47b3112b00cb6c1ae72d6d8a43e583af117ea.tar.gz
third_party-ruby-git-b0d47b3112b00cb6c1ae72d6d8a43e583af117ea.tar.xz
third_party-ruby-git-b0d47b3112b00cb6c1ae72d6d8a43e583af117ea.zip
significantly improved log performance
-rw-r--r--benchmark.rb30
-rw-r--r--lib/git/lib.rb2
-rw-r--r--lib/git/log.rb4
-rw-r--r--lib/git/object.rb2
-rw-r--r--tests/units/test_lib.rb5
-rw-r--r--tests/units/test_log.rb7
-rw-r--r--tests/units/test_object.rb6
7 files changed, 28 insertions, 28 deletions
diff --git a/benchmark.rb b/benchmark.rb
index 85ddd01..7fc0b5d 100644
--- a/benchmark.rb
+++ b/benchmark.rb
@@ -1,9 +1,9 @@
require 'fileutils'
require 'benchmark'
require 'rubygems'
-#require 'ruby-prof'
-#require_gem 'git', '1.0.2'
-require 'lib/git'
+require 'ruby-prof'
+require_gem 'git', '1.0.3'
+#require 'lib/git'
def main
@wbare = File.expand_path(File.join('tests', 'files', 'working.git'))
@@ -12,8 +12,9 @@ def main
g = Git.clone(@wbare, 'test')
g.chdir do
- n = 30
- #result = RubyProf.profile do
+ n = 40
+ result = RubyProf.profile do
+ puts "<pre>"
Benchmark.bm(8) do |x|
run_code(x, 'objects') do
@@ -94,22 +95,27 @@ def main
g.write_tree
end
end
- end
+ end rescue nil
x.report('archive ') do
n.times do
f = g.gcommit('v2.6').archive # returns path to temp file
end
end rescue nil
-
+
+
end
- #end
+ end
# Print a graph profile to text
- #printer = RubyProf::FlatPrinter.new(result)
- #printer.print(STDOUT, 0)
-
+ puts "</pre>"
+ printer = RubyProf::GraphHtmlPrinter.new(result)
+ printer.print(STDOUT, 1)
+ printer = RubyProf::FlatPrinter.new(result)
+ puts "<pre>"
+ printer.print(STDOUT, 1)
+ puts "</pre>"
end
end
end
@@ -148,4 +154,4 @@ def in_temp_dir(remove_after = true)
FileUtils.rm_r(tmp_path) if remove_after
end
-main() \ No newline at end of file
+main()
diff --git a/lib/git/lib.rb b/lib/git/lib.rb
index 76223de..c22042f 100644
--- a/lib/git/lib.rb
+++ b/lib/git/lib.rb
@@ -62,7 +62,7 @@ module Git
arr_opts = ['--pretty=oneline']
arr_opts << "-#{opts[:count]}" if opts[:count]
arr_opts << "--since=\"#{opts[:since]}\"" if opts[:since].is_a? String
- arr_opts << "#{opts[:between][0]}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
+ arr_opts << "#{opts[:between][0].to_s}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
arr_opts << opts[:object] if opts[:object].is_a? String
arr_opts << '-- ' + opts[:path_limiter] if opts[:path_limiter].is_a? String
diff --git a/lib/git/log.rb b/lib/git/log.rb
index eb625f3..c91538d 100644
--- a/lib/git/log.rb
+++ b/lib/git/log.rb
@@ -41,12 +41,12 @@ module Git
def between(sha1, sha2 = nil)
dirty_log
- @between = [@base.lib.revparse(sha1), @base.lib.revparse(sha2)]
+ @between = [sha1, sha2]
return self
end
def to_s
- self.map { |c| c.sha }.join("\n")
+ self.map { |c| c.to_s }.join("\n")
end
diff --git a/lib/git/object.rb b/lib/git/object.rb
index 2468615..aeeae89 100644
--- a/lib/git/object.rb
+++ b/lib/git/object.rb
@@ -42,7 +42,7 @@ module Git
end
def to_s
- sha
+ @objectish
end
def grep(string, path_limiter = nil, opts = {})
diff --git a/tests/units/test_lib.rb b/tests/units/test_lib.rb
index 5afb4ec..9a3479b 100644
--- a/tests/units/test_lib.rb
+++ b/tests/units/test_lib.rb
@@ -42,10 +42,7 @@ class TestLib < Test::Unit::TestCase
a = @lib.log_commits :count => 20, :between => ['v2.5', 'v2.6']
assert_equal(2, a.size)
- a = @lib.log_commits :count => 20, :object => 'example.txt'
- assert_equal(20, a.size)
-
- a = @lib.log_commits :count => 20, :object => 'ex_dir/ex.txt'
+ a = @lib.log_commits :count => 20, :path_limiter => 'ex_dir/'
assert_equal(1, a.size)
end
diff --git a/tests/units/test_log.rb b/tests/units/test_log.rb
index 7198b8a..5b41f39 100644
--- a/tests/units/test_log.rb
+++ b/tests/units/test_log.rb
@@ -32,13 +32,10 @@ class TestLog < Test::Unit::TestCase
end
def test_get_log_since_file
- l = @git.log.object('example.txt')
+ l = @git.log.path('example.txt')
assert_equal(30, l.size)
-
- l = @git.log.between('v2.5').object('example.txt')
- assert_equal(3, l.size)
- l = @git.log.between('v2.5', 'test').object('example.txt')
+ l = @git.log.between('v2.5', 'test').path('example.txt')
assert_equal(1, l.size)
end
diff --git a/tests/units/test_object.rb b/tests/units/test_object.rb
index 5b04054..a574919 100644
--- a/tests/units/test_object.rb
+++ b/tests/units/test_object.rb
@@ -50,9 +50,9 @@ class TestObject < Test::Unit::TestCase
end
def test_object_to_s
- assert_equal('1cc8667014381e2788a94777532a788307f38d26', @commit.to_s)
- assert_equal('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7', @tree.to_s)
- assert_equal('ba492c62b6227d7f3507b4dcc6e6d5f13790eabf', @blob.to_s)
+ assert_equal('1cc8667014381e2788a94777532a788307f38d26', @commit.sha)
+ assert_equal('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7', @tree.sha)
+ assert_equal('ba492c62b6227d7f3507b4dcc6e6d5f13790eabf', @blob.sha)
end
def test_object_size