File tree 7 files changed +28
-28
lines changed
7 files changed +28
-28
lines changed Original file line number Diff line number Diff line change 1
1
require 'fileutils'
2
2
require 'benchmark'
3
3
require 'rubygems'
4
- # require 'ruby-prof'
5
- # require_gem 'git', '1.0.2 '
6
- require 'lib/git'
4
+ require 'ruby-prof'
5
+ require_gem 'git' , '1.0.3 '
6
+ # require 'lib/git'
7
7
8
8
def main
9
9
@wbare = File . expand_path ( File . join ( 'tests' , 'files' , 'working.git' ) )
@@ -12,8 +12,9 @@ def main
12
12
g = Git . clone ( @wbare , 'test' )
13
13
g . chdir do
14
14
15
- n = 30
16
- #result = RubyProf.profile do
15
+ n = 40
16
+ result = RubyProf . profile do
17
+ puts "<pre>"
17
18
18
19
Benchmark . bm ( 8 ) do |x |
19
20
run_code ( x , 'objects' ) do
@@ -94,22 +95,27 @@ def main
94
95
g . write_tree
95
96
end
96
97
end
97
- end
98
+ end rescue nil
98
99
99
100
x . report ( 'archive ' ) do
100
101
n . times do
101
102
f = g . gcommit ( 'v2.6' ) . archive # returns path to temp file
102
103
end
103
104
end rescue nil
104
-
105
+
106
+
105
107
end
106
108
107
- # end
109
+ end
108
110
109
111
# Print a graph profile to text
110
- #printer = RubyProf::FlatPrinter.new(result)
111
- #printer.print(STDOUT, 0)
112
-
112
+ puts "</pre>"
113
+ printer = RubyProf ::GraphHtmlPrinter . new ( result )
114
+ printer . print ( STDOUT , 1 )
115
+ printer = RubyProf ::FlatPrinter . new ( result )
116
+ puts "<pre>"
117
+ printer . print ( STDOUT , 1 )
118
+ puts "</pre>"
113
119
end
114
120
end
115
121
end
@@ -148,4 +154,4 @@ def in_temp_dir(remove_after = true)
148
154
FileUtils . rm_r ( tmp_path ) if remove_after
149
155
end
150
156
151
- main ( )
157
+ main ( )
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ def log_commits(opts = {})
62
62
arr_opts = [ '--pretty=oneline' ]
63
63
arr_opts << "-#{ opts [ :count ] } " if opts [ :count ]
64
64
arr_opts << "--since=\" #{ opts [ :since ] } \" " if opts [ :since ] . is_a? String
65
- arr_opts << "#{ opts [ :between ] [ 0 ] } ..#{ opts [ :between ] [ 1 ] . to_s } " if ( opts [ :between ] && opts [ :between ] . size == 2 )
65
+ arr_opts << "#{ opts [ :between ] [ 0 ] . to_s } ..#{ opts [ :between ] [ 1 ] . to_s } " if ( opts [ :between ] && opts [ :between ] . size == 2 )
66
66
arr_opts << opts [ :object ] if opts [ :object ] . is_a? String
67
67
arr_opts << '-- ' + opts [ :path_limiter ] if opts [ :path_limiter ] . is_a? String
68
68
Original file line number Diff line number Diff line change @@ -41,12 +41,12 @@ def since(date)
41
41
42
42
def between ( sha1 , sha2 = nil )
43
43
dirty_log
44
- @between = [ @base . lib . revparse ( sha1 ) , @base . lib . revparse ( sha2 ) ]
44
+ @between = [ sha1 , sha2 ]
45
45
return self
46
46
end
47
47
48
48
def to_s
49
- self . map { |c | c . sha } . join ( "\n " )
49
+ self . map { |c | c . to_s } . join ( "\n " )
50
50
end
51
51
52
52
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ def setup
42
42
end
43
43
44
44
def to_s
45
- sha
45
+ @objectish
46
46
end
47
47
48
48
def grep ( string , path_limiter = nil , opts = { } )
Original file line number Diff line number Diff line change @@ -42,10 +42,7 @@ def test_log_commits
42
42
a = @lib . log_commits :count => 20 , :between => [ 'v2.5' , 'v2.6' ]
43
43
assert_equal ( 2 , a . size )
44
44
45
- a = @lib . log_commits :count => 20 , :object => 'example.txt'
46
- assert_equal ( 20 , a . size )
47
-
48
- a = @lib . log_commits :count => 20 , :object => 'ex_dir/ex.txt'
45
+ a = @lib . log_commits :count => 20 , :path_limiter => 'ex_dir/'
49
46
assert_equal ( 1 , a . size )
50
47
end
51
48
Original file line number Diff line number Diff line change @@ -32,13 +32,10 @@ def test_get_log_since
32
32
end
33
33
34
34
def test_get_log_since_file
35
- l = @git . log . object ( 'example.txt' )
35
+ l = @git . log . path ( 'example.txt' )
36
36
assert_equal ( 30 , l . size )
37
-
38
- l = @git . log . between ( 'v2.5' ) . object ( 'example.txt' )
39
- assert_equal ( 3 , l . size )
40
37
41
- l = @git . log . between ( 'v2.5' , 'test' ) . object ( 'example.txt' )
38
+ l = @git . log . between ( 'v2.5' , 'test' ) . path ( 'example.txt' )
42
39
assert_equal ( 1 , l . size )
43
40
end
44
41
Original file line number Diff line number Diff line change @@ -50,9 +50,9 @@ def test_commit_contents
50
50
end
51
51
52
52
def test_object_to_s
53
- assert_equal ( '1cc8667014381e2788a94777532a788307f38d26' , @commit . to_s )
54
- assert_equal ( '94c827875e2cadb8bc8d4cdd900f19aa9e8634c7' , @tree . to_s )
55
- assert_equal ( 'ba492c62b6227d7f3507b4dcc6e6d5f13790eabf' , @blob . to_s )
53
+ assert_equal ( '1cc8667014381e2788a94777532a788307f38d26' , @commit . sha )
54
+ assert_equal ( '94c827875e2cadb8bc8d4cdd900f19aa9e8634c7' , @tree . sha )
55
+ assert_equal ( 'ba492c62b6227d7f3507b4dcc6e6d5f13790eabf' , @blob . sha )
56
56
end
57
57
58
58
def test_object_size
You can’t perform that action at this time.
0 commit comments