Skip to content

Commit

Permalink
bunch of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed May 29, 2008
1 parent f978121 commit 1535929
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 26 deletions.
8 changes: 5 additions & 3 deletions PURE_TODO
Expand Up @@ -8,6 +8,11 @@ Completed
** lib/grit/tree.rb:16: output = repo.git.ls_tree({}, treeish, *paths)


lib/grit/commit.rb:74: repo.git.rev_list({}, ref).strip.split("\n").size
lib/grit/commit.rb:92: output = repo.git.rev_list(actual_options, ref)
lib/grit/commit.rb:94: output = repo.git.rev_list(actual_options.merge(:all => true))


Next to do
===========================
lib/grit/tag.rb:28: output = repo.git.for_each_ref(actual_options, "refs/tags")
Expand All @@ -19,9 +24,6 @@ lib/grit/config.rb:40: @repo.git.config(:list => true).split(/\n/)

May not be fast enough
=============================
lib/grit/commit.rb:74: repo.git.rev_list({}, ref).strip.split("\n").size
lib/grit/commit.rb:92: output = repo.git.rev_list(actual_options, ref)
lib/grit/commit.rb:94: output = repo.git.rev_list(actual_options.merge(:all => true))
lib/grit/blob.rb:58: data = repo.git.blame({:p => true}, commit, '--', file)


Expand Down
4 changes: 3 additions & 1 deletion lib/grit.rb
Expand Up @@ -32,9 +32,11 @@
module Grit
class << self
attr_accessor :debug
attr_accessor :use_git_ruby
end

self.debug = false
self.use_git_ruby = true

VERSION = '0.8.1'
VERSION = '0.8.2'
end
6 changes: 3 additions & 3 deletions lib/grit/git-ruby.rb
Expand Up @@ -8,9 +8,9 @@ module Grit
module GitRuby

class << self
attr_accessor :cache_client
attr_accessor :use_commit_db
end
self.cache_client = false
self.use_commit_db = false

attr_accessor :ruby_git_repo

Expand Down Expand Up @@ -69,7 +69,7 @@ def file_type(ref)
end

def ruby_git
@ruby_git_repo ||= Repository.new(@git_dir, GitRuby.cache_client)
@ruby_git_repo ||= Repository.new(self, @git_dir, GitRuby.use_commit_db)
end

end
Expand Down
9 changes: 6 additions & 3 deletions lib/grit/git-ruby/repository.rb
Expand Up @@ -13,6 +13,7 @@
require 'grit/git-ruby/internal/pack'
require 'grit/git-ruby/internal/loose'
require 'grit/git-ruby/object'
require 'grit/git-ruby/commit_db'

module Grit
module GitRuby
Expand All @@ -21,10 +22,12 @@ class Repository
class NoSuchShaFound < StandardError
end

attr_accessor :git_dir, :cache
attr_accessor :git_dir, :commit_db

def initialize(git_dir, cache_client = nil)
@cache = cache_client || false
def initialize(git_dir, commit_db = nil)
if use_commit_db
@commit_db = CommitDb.new(git_dir)
end
@git_dir = git_dir
end

Expand Down
8 changes: 8 additions & 0 deletions lib/grit/repo.rb
Expand Up @@ -60,6 +60,14 @@ def head
Head.current(self)
end


# Commits current index
#
# Returns true/false if commit worked
def commit_index(message)
self.git.commit({}, a, b, '--', *paths)
end

# An array of Tag objects that are available in this repo
#
# Returns Grit::Tag[] (baked)
Expand Down
9 changes: 7 additions & 2 deletions test/bench/benchmarks.rb
Expand Up @@ -5,8 +5,8 @@
require 'memcache'
require 'pp'

#require 'grit'
require '../../lib/grit'
gem 'grit', '=0.7.0'
#require '../../lib/grit'

def main
@wbare = File.expand_path(File.join('../../', 'test', 'dot_git'))
Expand All @@ -15,6 +15,7 @@ def main
#result = RubyProf.profile do

git = Grit::Repo.new('.')
puts Grit::VERSION
#Grit::GitRuby.cache_client = MemCache.new 'localhost:11211', :namespace => 'grit'
#Grit.debug = true

Expand Down Expand Up @@ -44,6 +45,10 @@ def main
git.commits('testing').map { |c| c.message }
end

run_code(x, 'big revlist') do
c = git.commits('master', 200)
end

run_code(x, 'log') do
log = git.log('master')
log.size
Expand Down
30 changes: 16 additions & 14 deletions test/bench/benchmarks.txt
@@ -1,21 +1,23 @@
Grit :
user system total real
packobj 0.030000 0.270000 1.380000 ( 1.507250)
commits 1 0.030000 0.070000 0.390000 ( 0.409931)
commits 2 0.110000 0.170000 0.860000 ( 0.896371)
log 0.350000 0.130000 0.850000 ( 0.875035)
diff 0.190000 0.140000 1.940000 ( 2.031911)
commit-diff 0.540000 0.220000 1.390000 ( 1.463839)
heads 0.010000 0.070000 0.390000 ( 0.413918)
packobj 0.030000 0.260000 1.320000 ( 1.344565)
commits 1 0.030000 0.070000 0.380000 ( 0.366209)
commits 2 0.110000 0.160000 0.830000 ( 0.802311)
big revlist 0.330000 0.130000 0.830000 ( 0.795258)
log 0.380000 0.140000 0.880000 ( 0.856951)
diff 0.330000 0.190000 2.080000 ( 2.072242)
commit-diff 0.690000 0.250000 1.560000 ( 1.521016)
heads 0.000000 0.070000 0.360000 ( 0.376296)


Grit (with GitRuby) :

user system total real
packobj 0.050000 0.010000 0.060000 ( 0.078318)
commits 1 0.150000 0.010000 0.160000 ( 0.174296)
commits 2 0.440000 0.040000 0.480000 ( 0.522310)
log 0.490000 0.040000 0.530000 ( 0.538128)
diff 0.370000 0.230000 2.250000 ( 2.255974)
commit-diff 0.580000 0.260000 1.500000 ( 1.553000)
heads 0.020000 0.100000 0.430000 ( 0.455464)
packobj 0.050000 0.000000 0.050000 ( 0.051167)
commits 1 0.140000 0.010000 0.150000 ( 0.164900)
commits 2 0.430000 0.030000 0.460000 ( 0.454646)
big revlist 1.540000 0.100000 1.640000 ( 1.637204)
log 0.480000 0.030000 0.510000 ( 0.512445)
diff 0.200000 0.190000 1.970000 ( 1.905014)
commit-diff 0.550000 0.240000 1.420000 ( 1.366508)
heads 0.020000 0.090000 0.410000 ( 0.402519)
22 changes: 22 additions & 0 deletions test/test_rubygit.rb
Expand Up @@ -45,6 +45,28 @@ def test_ls_tree_paths
assert_equal out, fixture('ls_tree_paths_ruby').chomp
end


def test_log
end

def test_rev_list
end

def test_rev_list_max_count
end

def test_rev_list_since
end

def test_rev_list_until
end

def test_rev_list_range
end

def test_rev_list_skip
end


def test_file_type
out = @git.file_type(@tree_sha).to_s
Expand Down

0 comments on commit 1535929

Please sign in to comment.