ruby-prof 0.6.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/CHANGES +116 -0
  2. data/LICENSE +23 -0
  3. data/README +307 -0
  4. data/Rakefile +141 -0
  5. data/bin/ruby-prof +192 -0
  6. data/examples/flat.txt +55 -0
  7. data/examples/graph.html +823 -0
  8. data/examples/graph.txt +170 -0
  9. data/ext/extconf.rb +21 -0
  10. data/ext/extconf.rb.rej +13 -0
  11. data/ext/measure_allocations.h +43 -0
  12. data/ext/measure_cpu_time.h +138 -0
  13. data/ext/measure_memory.h +42 -0
  14. data/ext/measure_process_time.h +41 -0
  15. data/ext/measure_wall_time.h +42 -0
  16. data/ext/ruby_prof.c +1628 -0
  17. data/lib/ruby-prof.rb +43 -0
  18. data/lib/ruby-prof/abstract_printer.rb +42 -0
  19. data/lib/ruby-prof/call_tree_printer.rb +76 -0
  20. data/lib/ruby-prof/call_tree_printer.rb.rej +27 -0
  21. data/lib/ruby-prof/flat_printer.rb +79 -0
  22. data/lib/ruby-prof/graph_html_printer.rb +255 -0
  23. data/lib/ruby-prof/graph_printer.rb +163 -0
  24. data/lib/ruby-prof/profile_test_case.rb +80 -0
  25. data/lib/ruby-prof/task.rb +147 -0
  26. data/lib/ruby_prof.so +0 -0
  27. data/lib/unprof.rb +8 -0
  28. data/rails_plugin/ruby-prof/init.rb +8 -0
  29. data/rails_plugin/ruby-prof/lib/profiling.rb +57 -0
  30. data/test/basic_test.rb +190 -0
  31. data/test/duplicate_names_test.rb +33 -0
  32. data/test/line_number_test.rb +69 -0
  33. data/test/measure_mode_test.rb +79 -0
  34. data/test/module_test.rb +57 -0
  35. data/test/no_method_class_test.rb +14 -0
  36. data/test/prime.rb +60 -0
  37. data/test/prime1.rb +17 -0
  38. data/test/prime2.rb +26 -0
  39. data/test/prime3.rb +17 -0
  40. data/test/prime_test.rb +24 -0
  41. data/test/printers_test.rb +74 -0
  42. data/test/profile_unit_test.rb +24 -0
  43. data/test/recursive_test.rb +144 -0
  44. data/test/singleton_test.rb +38 -0
  45. data/test/start_test.rb +24 -0
  46. data/test/test_helper.rb +55 -0
  47. data/test/test_suite.rb +19 -0
  48. data/test/thread_test.rb +135 -0
  49. data/test/timing_test.rb +133 -0
  50. metadata +116 -0
data/CHANGES ADDED
@@ -0,0 +1,116 @@
1
+ 0.6.0 (2007-02-03)
2
+ ========================
3
+
4
+ ruby-prof 0.6.0 adds support for Ruby 1.9 and memory profiling.
5
+
6
+ Features
7
+ --------
8
+ * Added support for ruby 1.9 (Shugo Maeda)
9
+ * Added support for outputting printer results to a String, Array or IO
10
+ object (Michael Granger)
11
+ * Add new memory profiling mode. Note this mode depends on a
12
+ patched Ruby interpreter (Alexander Dymo)
13
+
14
+ Fixes
15
+ -------
16
+ * Improvements to GraphHtmlPrinter including updated documentation,
17
+ fixes for min_time support, ability to specify templates using
18
+ strings or filenames, and table layout fixes (Makoto Kuwata)
19
+ * Fixes to scaling factor for calltrees so that precision is not lost
20
+ due to the conversion to doubles (Sylvain Joyeux)
21
+ * Changed constant ALLOCATED_OBJECTS to ALLOCATIONS in the C code to
22
+ match the Ruby code (Sylvain Joyeux)
23
+ * Added support for calltree printer to ruby-prof binary script (Sylvain Joyeux)
24
+ * Fix support for the allocator measure mode to extconf.rb (Sylvain Joyeux)
25
+ * Honor measure mode when specified on the command line (Sylvain Joyeux)
26
+ * Sorting of methods by total time was incorrect (Dan Fitch, Charlie Savage)
27
+ * Fix ruby-prof to work with the latest version of GEMS (Alexander Dymo)
28
+ * Always define MEASURE_CPU_TIME and MEASURE_ALLOCATIONS in Ruby code, but
29
+ set their values to nil if the functionality is not available.
30
+
31
+
32
+ 0.5.2 (2007-07-19)
33
+ ========================
34
+
35
+ ruby-prof 0.5.2 is a bug fix release.
36
+
37
+ Fixes
38
+ -------
39
+ * Include missing rails plugin
40
+
41
+
42
+ 0.5.1 (2007-07-18)
43
+ ========================
44
+
45
+ ruby-prof 0.5.1 is a bug fix and performance release.
46
+
47
+ Performance
48
+ --------
49
+ * Significantly reduced the number of thread lookups by
50
+ caching the last executed thread.
51
+
52
+ Fixes
53
+ -------
54
+ * Properly escape method names in HTML reports
55
+ * Fix use of -m and --min-percent command line switches
56
+ * Default source file information to ruby_runtime#0 for c calls
57
+ * Moved rails_plugin to top level so it is more obvious
58
+ * Updated rails_plugin to write reports to the current
59
+ Rails log directory
60
+ * Added additional tests
61
+
62
+
63
+ 0.5.0 (2007-07-09)
64
+ ========================
65
+
66
+ Features
67
+ --------
68
+ * Added support for timing multi-threaded applications
69
+ * Added support for 64 bit systems (patch from Diego 'Flameeyes' Petten)
70
+ * Added suport for outputting data in the format used by
71
+ KCacheGrind (patch from Carl Shimer)
72
+ * Add filename and line numbers to call tree information (patch from Carl Shimer)
73
+ * Added Visual Studio 2005 project file.
74
+ * Added replace-progname switch, als rcov.
75
+ * Added better support for recursive methods
76
+ * Added better support for profiling Rails applications
77
+
78
+ Fixes
79
+ -------
80
+ * Fixes bug when the type of an attached object (singleton) is inherited
81
+ from T_OBJECT as opposed to being a T_OBJECT (identified by Francis Cianfrocca)
82
+ * ruby-prof now works in IRB.
83
+ * Fix sort order in reports.
84
+ * Fixed rdoc compile error.
85
+ * Fix tabs in erb template for graph html report on windows.
86
+
87
+ 0.4.1 (2006-06-26)
88
+ ========================
89
+
90
+ Features
91
+ --------
92
+ * Added a RubyProf.running? method to indicate whether a profile is in progress.
93
+ * Added tgz and zip archives to release
94
+
95
+ Fixes
96
+ -------
97
+ * Duplicate method names are now allowed
98
+ * The documentation has been updated to show the correct API usage is RubyProf.stop not RubyProf.end
99
+
100
+
101
+ 0.4.0 (2006-06-16)
102
+ ========================
103
+ Features
104
+ --------
105
+ * added support for call graphs
106
+ * added support for printers. Currently there is a FlatPrinter,
107
+ GraphPrinter and GraphHtmlPrinter.
108
+ * added support for recursive methods
109
+ * added Windows support
110
+ * now packaged as a RubyGem
111
+
112
+ Fixes
113
+ -------
114
+ * Fixes bug where RubyProf would crash depending on the
115
+ way it was invoked - for example, it did not run when
116
+ used with Arachno Ruby's customized version of Ruby.
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (C) 2005 Shugo Maeda <shugo@ruby-lang.org>
2
+ All rights reserved.
3
+ *
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions
6
+ are met:
7
+ 1. Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+ 2. Redistributions in binary form must reproduce the above copyright
10
+ notice, this list of conditions and the following disclaimer in the
11
+ documentation and/or other materials provided with the distribution.
12
+ *
13
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
14
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
17
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23
+ SUCH DAMAGE.
data/README ADDED
@@ -0,0 +1,307 @@
1
+ = ruby-prof
2
+
3
+ == Overview
4
+
5
+ ruby-prof is a fast code profiler for Ruby. Its features include:
6
+
7
+ * Speed - it is a C extension and therefore many times faster than the standard Ruby profiler.
8
+ * Modes - Ruby prof can measure a number of different parameters, including
9
+ call times, memory usage and object allocations.
10
+ * Reports - can generate text and cross-referenced html reports
11
+ - Flat Profiles - similar to the reports generated by the standard Ruby profiler
12
+ - Graph profiles - similar to GProf, these show how long a method runs, which methods call it and which methods it calls.
13
+ - Call tree profiles - outputs results in the calltree format suitable for the KCacheGrind profiling tool.
14
+ * Threads - supports profiling multiple threads simultaneously
15
+ * Recursive calls - supports profiling recursive method calls
16
+
17
+
18
+ == Requirements
19
+
20
+ ruby-prof requires Ruby 1.8.4 or higher.
21
+
22
+ If you are running Linux or Unix you'll need a C compiler so the extension
23
+ can be compiled when it is installed.
24
+
25
+ If you are running Windows, then install the Windows specific RubyGem which
26
+ includes an already built extension.
27
+
28
+
29
+ == Install
30
+
31
+ The easiest way to install ruby-prof is by using Ruby Gems. To install:
32
+
33
+ <tt>gem install ruby-prof</tt>
34
+
35
+ If you are running Windows, make sure to install the Win32 RubyGem which
36
+ includes a pre-built binary.
37
+
38
+ ruby-prof is also available as a tarred gzip archive and zip archive.
39
+
40
+ == Usage
41
+
42
+ There are three ways of running ruby-prof.
43
+
44
+ === ruby-prof executable
45
+
46
+ The first is to use ruby-prof to run the Ruby program
47
+ you want to profile. For more information refer to
48
+ the ruby-prof documentation[link:files/bin/ruby-prof.html].
49
+
50
+ === ruby-prof API
51
+
52
+ The second way is to use the ruby-prof API to profile
53
+ particular segments of code.
54
+
55
+ require 'ruby-prof'
56
+
57
+ # Profile the code
58
+ RubyProf.start
59
+ ...
60
+ [code to profile]
61
+ ...
62
+ result = RubyProf.stop
63
+
64
+ # Print a flat profile to text
65
+ printer = RubyProf::FlatPrinter.new(result)
66
+ printer.print(STDOUT, 0)
67
+
68
+ Alternatively, you can use a block to tell ruby-prof what
69
+ to profile:
70
+
71
+ require 'ruby-prof'
72
+
73
+ # Profile the code
74
+ result = RubyProf.profile do
75
+ ...
76
+ [code to profile]
77
+ ...
78
+ end
79
+
80
+ # Print a graph profile to text
81
+ printer = RubyProf::GraphPrinter.new(result)
82
+ printer.print(STDOUT, 0)
83
+
84
+
85
+ === require unprof
86
+
87
+ The third way of using ruby-prof is by requiring unprof.rb:
88
+
89
+ require 'unprof'
90
+
91
+ This will start profiling immediately and will output the results
92
+ using a flat profile report.
93
+
94
+ This method is provided for backwards compatibility. Using
95
+ {ruby-prof}[link:files/bin/ruby-prof.html] provides more flexibility.
96
+
97
+
98
+ == Reports
99
+
100
+ ruby-prof can generate a number of different reports:
101
+
102
+ * Flat Reports
103
+ * Graph Reports
104
+ * HTML Graph Reports
105
+ * Call graphs
106
+
107
+ Flat profiles show the overall time spent in each method. They
108
+ are a good of quickly identifying which methods take the most time.
109
+ An example of a flat profile and an explanation can be found in
110
+ {examples/flat.txt}[link:files/examples/flat_txt.html].
111
+
112
+ Graph profiles also show the overall time spent in each method.
113
+ In addition, they also show which methods call the current
114
+ method and which methods its calls. Thus they are good for
115
+ understanding how methods gets called and provide insight into
116
+ the flow of your program. An example text graph profile
117
+ is located at {examples/graph.txt}[link:files/examples/graph_txt.html].
118
+
119
+ HTML Graph profiles are the same as graph profiles, except
120
+ output is generated in hyper-linked HTML. Since graph profiles
121
+ can be quite large, the embedded links make it much easier to
122
+ navigate the results. An example html graph profile
123
+ is located at {examples/graph.html}[link:files/examples/graph_html.html].
124
+
125
+ HTML Graph profiles are the same as graph profiles, except
126
+ output is generated in hyper-linked HTML. Since graph profiles
127
+ can be quite large, the embedded links make it much easier to
128
+ navigate the results. An example html graph profile
129
+ is located at {examples/graph.html}[link:files/examples/graph_html.html].
130
+
131
+ Call graphs output results in the calltree profile format which is used
132
+ by KCachegrind. Call graph support was generously donated by Carl Shimer.
133
+ More information about the format can be found at
134
+ the {KCachegrind}[link:http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindCalltreeFormat] site.
135
+
136
+ == Printers
137
+
138
+ Reports are created by printers. Supported printers include:
139
+
140
+ * RubyProf::FlatPrinter - Creates a flat report in text format
141
+ * RubyProf::GraphPrinter - Creates a call graph report in text format
142
+ * RubyProf::GraphHtmlPrinter - Creates a call graph report in HTML (separate files per thread)
143
+ * RubyProf::CallTreePrinter - Creates a call tree report compatible with KCachegrind.
144
+
145
+ To use a printer:
146
+
147
+ result = RubyProf.end
148
+ printer = RubyProf::GraphPrinter.new(result)
149
+ printer.print(STDOUT, 0)
150
+
151
+ The first parameter is any writable IO object such as STDOUT or a file.
152
+ The second parameter, which has a default value of 0, specifies
153
+ the minimum percentage a method must take to be printed. Percentages
154
+ should be specified as integers in the range 0 to 100. For more
155
+ information please see the documentation for the different printers.
156
+
157
+
158
+ == Measurements
159
+
160
+ Depending on the mode and platform, ruby-prof can measure various
161
+ aspects of a Ruby program. Supported measurements include:
162
+
163
+ * process time
164
+ * wall time
165
+ * cpu time
166
+ * object allocations
167
+ * memory usage
168
+
169
+ Process time measures the time used by a process between any two moments.
170
+ It is unaffected by other processes concurrently running
171
+ on the system. Note that Windows does not support measuring process
172
+ times - therefore, all measurements on Windows use wall time.
173
+
174
+ Wall time measures the real-world time elapsed between any two moments.
175
+ If there are other processes concurrently running on the system
176
+ that use significant CPU or disk time during a profiling run
177
+ then the reported results will be too large.
178
+
179
+ CPU time uses the CPU clock counter to measure time. The returned
180
+ values are dependent on the correctly setting the CPU's frequency.
181
+ This mode is only supported on Pentium or PowerPC platforms.
182
+
183
+ Object allocation reports show how many objects each method in
184
+ a program allocates. This support was added by Sylvain Joyeux
185
+ and requires a patched Ruby interpreter. For more information, see:
186
+ http://rubyforge.org/tracker/index.php?func=detail&aid=11497&group_id=426&atid=1700
187
+
188
+ Memory usage reports show how much memory each method in a program
189
+ uses. This support was added by Alexander Dymo and requires a
190
+ patched Ruby interpreter. For more information, see:
191
+ http://rubyforge.org/tracker/index.php?func=detail&aid=17676&group_id=1814&atid=7062.
192
+
193
+
194
+ To set the measurement:
195
+
196
+ * RubyProf.measure_mode = RubyProf::PROCESS_TIME
197
+ * RubyProf.measure_mode = RubyProf::WALL_TIME
198
+ * RubyProf.measure_mode = RubyProf::CPU_TIME
199
+ * RubyProf.measure_mode = RubyProf::ALLOCATIONS
200
+ * RubyProf.measure_mode = RubyProf::MEMORY
201
+
202
+ The default value is RubyProf::PROCESS_TIME.
203
+
204
+ You may also specify the measure_mode by using the RUBY_PROF_MEASURE_MODE
205
+ environment variable:
206
+
207
+ * export RUBY_PROF_MEASURE_MODE=process
208
+ * export RUBY_PROF_MEASURE_MODE=wall
209
+ * export RUBY_PROF_MEASURE_MODE=cpu
210
+ * export RUBY_PROF_MEASURE_MODE=allocations
211
+
212
+ Note that these values have changed since ruby-prof-0.3.0.
213
+
214
+ On Linux, process time is measured using the clock method provided
215
+ by the C runtime library. Note that the clock method does not
216
+ report time spent in the kernel or child processes and therefore
217
+ does not measure time spent in methods such as Kernel.sleep method.
218
+ If you need to measure these values, then use wall time. Wall time
219
+ is measured using the gettimeofday kernel method.
220
+
221
+ On Windows, timings are always wall times. If you set the clock
222
+ mode to PROCESS_TIME, then timing are read using the clock method
223
+ provided by the C runtime library. Note though, these values are
224
+ wall times on Windows and not process times like on Linux.
225
+ Wall time is measured using the GetLocalTime API.
226
+
227
+ If you use wall time, the results will be affected by other
228
+ processes running on your computer, network delays, disk access,
229
+ etc. As result, for the best results, try to make sure your
230
+ computer is only performing your profiling run and is
231
+ otherwise quiescent.
232
+
233
+ On both platforms, cpu time is measured using the RDTSC assembly
234
+ function provided by the Pentium and PowerPC platforms. CPU time
235
+ is dependent on the cpu's frequency. On Linux, ruby-prof attempts
236
+ to read this value from "/proc/cpuinfo." On Windows, you must
237
+ specify the clock frequency. This can be done using the
238
+ RUBY_PROF_CPU_FREQUENCY environment variable:
239
+
240
+ export RUBY_PROF_CPU_FREQUENCY=<value>
241
+
242
+ You can also directly set the cpu frequency by calling:
243
+
244
+ RubyProf.cpu_frequency = <value>
245
+
246
+
247
+ == Recursive Calls
248
+
249
+ Recursive calls occur when method A calls method A and cycles
250
+ occur when method A calls method B calls method C calls method A.
251
+ ruby-prof detects both direct recursive calls and cycles. Both
252
+ are indicated in reports by a dash and number following a method
253
+ name. For example, here is a flat profile from the test method
254
+ RecursiveTest#test_recursive:
255
+
256
+
257
+ %self total self wait child calls name
258
+ 100.00 2.00 2.00 0.00 0.00 2 Kernel#sleep
259
+ 0.00 2.00 0.00 0.00 2.00 0 RecursiveTest#test_cycle
260
+ 0.00 0.00 0.00 0.00 0.00 2 Fixnum#==
261
+ 0.00 0.00 0.00 0.00 0.00 2 Fixnum#-
262
+ 0.00 1.00 0.00 0.00 1.00 1 Object#sub_cycle-1
263
+ 0.00 2.00 0.00 0.00 2.00 1 Object#sub_cycle
264
+ 0.00 2.00 0.00 0.00 2.00 1 Object#cycle
265
+ 0.00 1.00 0.00 0.00 1.00 1 Object#cycle-1
266
+
267
+ Notice the presence of Object#cycle and Object#cycle-1. The -1 means
268
+ the method was either recursively called (directly or indirectly).
269
+
270
+ However, the self time values for recursive calls should always
271
+ be accurate. It is also believed that the total times are
272
+ accurate, but these should be carefully analyzed to verify their veracity.
273
+
274
+ == Multi-threaded Applications
275
+
276
+ Unfortunately, Ruby does not provide an internal api
277
+ for detecting thread context switches. As a result, the
278
+ timings ruby-prof reports for each thread may be slightly
279
+ inaccurate. In particular, this will happen for newly
280
+ spanned threads that immediately go to sleep. For instance,
281
+ if you use Ruby's timeout library to wait for 2 seconds,
282
+ the 2 seconds will be assigned to the foreground thread
283
+ and not the newly created background thread. These errors
284
+ can largely be avoided if the background thread performs an
285
+ operation before going to sleeep.
286
+
287
+
288
+ == Performance
289
+
290
+ Significant effort has been put into reducing ruby-prof's overhead
291
+ as much as possible. Our tests show that the overhead associated
292
+ with profiling code varies considerably with the code being
293
+ profiled. Most programs will run approximately twice as slow
294
+ while highly recursive programs (like the fibonacci series test)
295
+ will run three times slower.
296
+
297
+ == Windows Binary
298
+
299
+ The Windows binary is built with the latest version of MinGW. The source
300
+ repository also includes a Microsoft VC++ 2005 solution. If you wish to run
301
+ a debug version of ruby-prof on Windows, then it is highly recommended
302
+ you use VC++.
303
+
304
+
305
+ == License
306
+
307
+ See LICENSE for license information.
data/Rakefile ADDED
@@ -0,0 +1,141 @@
1
+ require 'rubygems'
2
+ require 'date'
3
+ require 'rake/gempackagetask'
4
+ require 'rake/rdoctask'
5
+ require 'date'
6
+
7
+ SO_NAME = "ruby_prof.so"
8
+
9
+ # ------- Default Package ----------
10
+ RUBY_PROF_VERSION = "0.6.0"
11
+
12
+ FILES = FileList[
13
+ 'Rakefile',
14
+ 'README',
15
+ 'LICENSE',
16
+ 'CHANGES',
17
+ 'bin/*',
18
+ 'lib/**/*',
19
+ 'rails_plugin/**/*',
20
+ 'examples/*',
21
+ 'ext/*',
22
+ 'doc/**/*',
23
+ 'test/*'
24
+ ]
25
+
26
+ # Default GEM Specification
27
+ default_spec = Gem::Specification.new do |spec|
28
+ spec.name = "ruby-prof"
29
+
30
+ spec.homepage = "http://rubyforge.org/projects/ruby-prof/"
31
+ spec.summary = "Fast Ruby profiler"
32
+ spec.description = <<-EOF
33
+ ruby-prof is a fast code profiler for Ruby. It is a C extension and
34
+ therefore is many times faster than the standard Ruby profiler. It
35
+ supports both flat and graph profiles. For each method, graph profiles
36
+ show how long the method ran, which methods called it and which
37
+ methods it called. RubyProf generate both text and html and can output
38
+ it to standard out or to a file.
39
+ EOF
40
+
41
+ spec.version = RUBY_PROF_VERSION
42
+
43
+ spec.author = "Shugo Maeda and Charlie Savage"
44
+ spec.email = "shugo@ruby-lang.org and cfis@savagexi.com"
45
+ spec.platform = Gem::Platform::RUBY
46
+ spec.require_path = "lib"
47
+ spec.bindir = "bin"
48
+ spec.executables = ["ruby-prof"]
49
+ spec.extensions = ["ext/extconf.rb"]
50
+ spec.files = FILES.to_a
51
+ spec.test_files = Dir["test/test_*.rb"]
52
+
53
+
54
+ spec.required_ruby_version = '>= 1.8.4'
55
+ spec.date = DateTime.now
56
+ spec.rubyforge_project = 'ruby-prof'
57
+
58
+ # rdoc
59
+ spec.has_rdoc = true
60
+ spec.rdoc_options << "--title" << "ruby-prof"
61
+ # Show source inline with line numbers
62
+ spec.rdoc_options << "--inline-source" << "--line-numbers"
63
+ # Make the readme file the start page for the generated html
64
+ spec.rdoc_options << '--main' << 'README'
65
+ spec.extra_rdoc_files = ['bin/ruby-prof',
66
+ 'ext/ruby_prof.c',
67
+ 'examples/flat.txt',
68
+ 'examples/graph.txt',
69
+ 'examples/graph.html',
70
+ 'README',
71
+ 'LICENSE']
72
+
73
+ end
74
+
75
+ # Rake task to build the default package
76
+ Rake::GemPackageTask.new(default_spec) do |pkg|
77
+ pkg.need_tar = true
78
+ pkg.need_zip = true
79
+ end
80
+
81
+
82
+ # ------- Windows Package ----------
83
+ # Windows specification
84
+ win_spec = default_spec.clone
85
+ win_spec.extensions = []
86
+ win_spec.platform = Gem::Platform::CURRENT
87
+ win_spec.files += ["lib/#{SO_NAME}"]
88
+
89
+ desc "Create Windows Gem"
90
+ task :create_win32_gem do
91
+ # Copy the win32 extension built by MingW - easier to install
92
+ # since there are no dependencies of msvcr80.dll
93
+ current_dir = File.expand_path(File.dirname(__FILE__))
94
+ source = File.join(current_dir, "mingw", SO_NAME)
95
+ target = File.join(current_dir, "lib", SO_NAME)
96
+ cp(source, target)
97
+
98
+ # Create the gem, then move it to pkg
99
+ Gem::Builder.new(win_spec).build
100
+ gem_file = "#{win_spec.name}-#{win_spec.version}-#{win_spec.platform}.gem"
101
+ mv(gem_file, "pkg/#{gem_file}")
102
+
103
+ # Remove win extension from top level directory
104
+ rm(target)
105
+ end
106
+
107
+
108
+ task :package => :create_win32_gem
109
+
110
+ # --------- RDoc Documentation ------
111
+ desc "Generate rdoc documentation"
112
+ Rake::RDocTask.new("rdoc") do |rdoc|
113
+ rdoc.rdoc_dir = 'doc'
114
+ rdoc.title = "ruby-prof"
115
+ # Show source inline with line numbers
116
+ rdoc.options << "--inline-source" << "--line-numbers"
117
+ # Make the readme file the start page for the generated html
118
+ rdoc.options << '--main' << 'README'
119
+ rdoc.rdoc_files.include('bin/**/*',
120
+ 'doc/*.rdoc',
121
+ 'examples/flat.txt',
122
+ 'examples/graph.txt',
123
+ 'examples/graph.html',
124
+ 'lib/**/*.rb',
125
+ 'ext/**/ruby_prof.c',
126
+ 'README',
127
+ 'LICENSE')
128
+ end
129
+
130
+
131
+ # --------- Publish to RubyForge ----------------
132
+ desc "Publish ruby-prof to RubyForge."
133
+ task :publish do
134
+ require 'rake/contrib/sshpublisher'
135
+
136
+ # Get ruby-prof path
137
+ ruby_prof_path = File.expand_path(File.dirname(__FILE__))
138
+
139
+ publisher = Rake::SshDirPublisher.new("cfis@rubyforge.org",
140
+ "/var/www/gforge-projects/ruby-prof", ruby_prof_path)
141
+ end