public
Description: RedCloth is a Ruby library for converting Textile into HTML.
Homepage: http://code.whytheluckystiff.net/redcloth/
Clone URL: git://github.com/jgarber/redcloth.git
Search Repo:
Click here to lend your support to: redcloth and make a donation at www.pledgie.com !
Wrote a rake task to benchmark compilaton time/memory, test time/memory, 
and final size.
Switched Ragel code generation style to the best.
jgarber (author)
Fri Apr 18 14:34:02 -0700 2008
commit  718a1cf65668c1dafdb4a7cdeaa7019648cafffd
tree    51fd0687df7053947928d3ca1bafa2c3e40272df
parent  7d9ad50b51d35db212587a3e9deeb1b4213ac721
...
11
12
13
14
15
 
 
16
17
18
...
124
125
126
 
127
128
129
130
131
 
132
133
134
...
212
213
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
...
11
12
13
 
 
14
15
16
17
18
...
124
125
126
127
128
129
130
131
 
132
133
134
135
...
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
0
@@ -11,8 +11,8 @@ OLD_NAME = "RedCloth"
0
 SUMMARY = "a fast library for formatting Textile as HTML"
0
 REV = `svn info`[/Revision: (\d+)/, 1] rescue nil
0
 VERS = ENV['VERSION'] || "3" + (REV ? ".#{REV}" : "")
0
-CLEAN.include ['ext/redcloth_scan/*.{bundle,so,obj,pdb,lib,def,exp}', 'ext/redcloth_scan/Makefile',
0
- '**/.*.sw?', '*.gem', '.config']
0
+CLEAN.include ['ext/redcloth_scan/*.{bundle,so,obj,pdb,lib,def,exp,c,o,xml}', 'ext/redcloth_scan/Makefile', '**/.*.sw?', '*.gem', '.config']
0
+CLOBBER.include ['lib/*.{bundle,so,obj,pdb,lib,def,exp}']
0
 
0
 desc "Does a full compile, test run"
0
 task :default => [:compile, :test]
0
@@ -124,11 +124,12 @@ task "lib" do
0
 end
0
 
0
 ["#{ext}/redcloth_scan.c","#{ext}/redcloth_inline.c"].each do |name|
0
+ @code_style ||= "T0"
0
   source = name.sub(/\.c$/, '.rl')
0
   file name => [source, "#{ext}/redcloth_common.rl", "#{ext}/redcloth.h"] do
0
     @ragel_v ||= `ragel -v`[/(version )(\S*)/,2].split('.').map{|s| s.to_i}
0
     if @ragel_v[0] > 6 || (@ragel_v[0] == 6 && @ragel_v[1] >= 1)
0
- sh %{ragel #{source} -G2 -o #{name}}
0
+ sh %{ragel #{source} -#{@code_style} -o #{name}}
0
     else
0
       STDERR.puts "Ragel 6.1 or greater is required to generate #{name}."
0
       exit(1)
0
@@ -212,3 +213,38 @@ end
0
 EOD
0
   end
0
 end
0
+
0
+RAGEL_CODE_GENERATION_STYLES = {
0
+ 'T0' => "Table driven FSM (default)",
0
+ 'T1' => "Faster table driven FSM",
0
+ 'F0' => "Flat table driven FSM",
0
+ 'F1' => "Faster flat table-driven FSM",
0
+ 'G0' => "Goto-driven FSM",
0
+ 'G1' => "Faster goto-driven FSM",
0
+ 'G2' => "Really fast goto-driven FSM"
0
+}
0
+
0
+task :optimize do
0
+ require 'extras/ragel_profiler'
0
+ results = []
0
+ RAGEL_CODE_GENERATION_STYLES.each do |style, name|
0
+ @code_style = style
0
+ profiler = RagelProfiler.new(style + " " + name)
0
+
0
+ # Hack to get everything to invoke again. Could use #execute, but then it
0
+ # doesn't execute prerequisites the second+ time
0
+ Rake::Task.tasks.each {|t| t.instance_eval "@already_invoked = false" }
0
+
0
+ Rake::Task['clobber'].invoke
0
+
0
+ profiler.measure(:compile) do
0
+ Rake::Task['compile'].invoke
0
+ end
0
+ profiler.measure(:test) do
0
+ Rake::Task['test'].invoke
0
+ end
0
+ profiler.ext_size(ext_so)
0
+
0
+ end
0
+ puts RagelProfiler.results
0
+end
0
\ No newline at end of file
...
2
3
4
5
6
 
 
 
7
8
...
2
3
4
 
 
5
6
7
8
9
0
@@ -2,7 +2,8 @@ require 'mkmf'
0
 
0
 $CFLAGS << " -O0 " # do not optimize (takes too much memory and performance gain is negligeable)
0
 
0
-dir_config("redcloth_scan")
0
-have_library("c", "main")
0
+### It seems to work fine without these
0
+# dir_config("redcloth_scan")
0
+# have_library("c", "main")
0
 
0
 create_makefile("redcloth_scan")

Comments

    No one has commented yet.