Top Level Namespace

Defined Under Namespace

Modules: Difference, Fugit, Grit, IconLoader, Lazy, Open3, Wx Classes: IO

Constant Summary collapse

PACK_SIGNATURE =
"PACK"
PACK_IDX_SIGNATURE =
"\377tOc"

Constants included from IconLoader

IconLoader::IconBasePath

Instance Method Summary collapse

Methods included from Fugit::GraphRenderer

#graphify

Methods included from IconLoader

#get_icon

Instance Method Details

#in_temp_dir(remove_after = true) ⇒ Object



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/grit/benchmarks.rb', line 115

def in_temp_dir(remove_after = true)
  filename = 'git_test' + Time.now.to_i.to_s + rand(300).to_s.rjust(3, '0')
  tmp_path = File.join("/tmp/", filename)
  FileUtils.mkdir(tmp_path)
  Dir.chdir tmp_path do
    FileUtils.cp_r(@wbare, File.join(tmp_path, '.git'))
    yield tmp_path
  end
  puts tmp_path
  #FileUtils.rm_r(tmp_path) if remove_after
end

#mainObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/grit/benchmarks.rb', line 12

def main
  @wbare = File.expand_path(File.join('test', 'dot_git'))
  
  in_temp_dir do
    #result = RubyProf.profile do

      git = Grit::Repo.new('.')
      puts Grit::VERSION
      
      Grit::GitRuby.use_commit_db = true
      #Grit::GitRuby.cache_client = MemCache.new 'localhost:11211', :namespace => 'grit'
      #Grit.debug = true
    
      #pp Grit::GitRuby.cache_client.stats 
    
      commit1 = '5e3ee1198672257164ce3fe31dea3e40848e68d5'
      commit2 = 'ca8a30f5a7f0f163bbe3b6f0abf18a6c83b0687a'
    
      Benchmark.bm(8) do |x|
            
        run_code(x, 'packobj') do
          @commit = git.commit('5e3ee1198672257164ce3fe31dea3e40848e68d5')
          @tree = git.tree('cd7422af5a2e0fff3e94d6fb1a8fff03b2841881')
          @blob = git.blob('4232d073306f01cf0b895864e5a5cfad7dd76fce')
          @commit.parents[0].parents[0].parents[0]
        end

        run_code(x, 'commits 1') do
          git.commits.size
        end
              
        run_code(x, 'commits 2') do
          log = git.commits('master', 15)
          log.size
          log.size
          log.first
          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
          log.size
          log.first
        end

        run_code(x, 'diff') do
          c = git.diff(commit1, commit2)
        end

        run_code(x, 'commit-diff') do
          c = git.commit_diff(commit1)
        end

        run_code(x, 'heads') do
          c = git.heads.collect { |b| b.commit.id }
        end

       # run_code(x, 'config', 100) do
       #   c = git.config['user.name']
       #   c = git.config['user.email']
       # end

        #run_code(x, 'commit count') do
        #  c = git.commit_count('testing')
        #end


      end
    #end

    #printer = RubyProf::FlatPrinter.new(result)
    #printer.print(STDOUT, 0)
    
  end


end

#new_file(name, contents) ⇒ Object



108
109
110
111
112
# File 'lib/grit/benchmarks.rb', line 108

def new_file(name, contents)
  File.open(name, 'w') do |f|
    f.puts contents
  end
end

#run_code(x, name, times = 30) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
# File 'lib/grit/benchmarks.rb', line 96

def run_code(x, name, times = 30)
    x.report(name.ljust(12)) do
      for i in 1..times do
        yield i
      end
    end
  
  #end
  
  # Print a graph profile to text
end