Changeset 300

Show
Ignore:
Timestamp:
04/18/2008 16:34:02 (7 months ago)
Author:
jgarber
Message:

Wrote a rake task to benchmark compilaton time/memory, test time/memory, and final size.
Switched Ragel code generation style to the best.

Location:
trunk
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/Rakefile

    r297 r300  
    1212REV = `svn info`[/Revision: (\d+)/, 1] rescue nil 
    1313VERS = ENV['VERSION'] || "3" + (REV ? ".#{REV}" : "") 
    14 CLEAN.include ['ext/redcloth_scan/*.{bundle,so,obj,pdb,lib,def,exp}', 'ext/redcloth_scan/Makefile',  
    15                '**/.*.sw?', '*.gem', '.config'] 
     14CLEAN.include ['ext/redcloth_scan/*.{bundle,so,obj,pdb,lib,def,exp,c,o,xml}', 'ext/redcloth_scan/Makefile', '**/.*.sw?', '*.gem', '.config'] 
     15CLOBBER.include ['lib/*.{bundle,so,obj,pdb,lib,def,exp}'] 
    1616 
    1717desc "Does a full compile, test run" 
     
    125125 
    126126["#{ext}/redcloth_scan.c","#{ext}/redcloth_inline.c"].each do |name| 
     127  @code_style ||= "T0" 
    127128  source = name.sub(/\.c$/, '.rl') 
    128129  file name => [source, "#{ext}/redcloth_common.rl", "#{ext}/redcloth.h"] do 
    129130    @ragel_v ||= `ragel -v`[/(version )(\S*)/,2].split('.').map{|s| s.to_i} 
    130131    if @ragel_v[0] > 6 || (@ragel_v[0] == 6 && @ragel_v[1] >= 1) 
    131       sh %{ragel #{source} -G2 -o #{name}} 
     132      sh %{ragel #{source} -#{@code_style} -o #{name}} 
    132133    else 
    133134      STDERR.puts "Ragel 6.1 or greater is required to generate #{name}." 
     
    213214  end 
    214215end 
     216 
     217RAGEL_CODE_GENERATION_STYLES = { 
     218  'T0' => "Table driven FSM (default)", 
     219  'T1' => "Faster table driven FSM", 
     220  'F0' => "Flat table driven FSM", 
     221  'F1' => "Faster flat table-driven FSM", 
     222  'G0' => "Goto-driven FSM", 
     223  'G1' => "Faster goto-driven FSM", 
     224  'G2' => "Really fast goto-driven FSM" 
     225} 
     226 
     227task :optimize do 
     228  require 'extras/ragel_profiler' 
     229  results = [] 
     230  RAGEL_CODE_GENERATION_STYLES.each do |style, name| 
     231    @code_style = style 
     232    profiler = RagelProfiler.new(style + " " + name) 
     233     
     234    # Hack to get everything to invoke again.  Could use #execute, but then it  
     235    # doesn't execute prerequisites the second+ time 
     236    Rake::Task.tasks.each {|t| t.instance_eval "@already_invoked = false" } 
     237     
     238    Rake::Task['clobber'].invoke 
     239     
     240    profiler.measure(:compile) do 
     241      Rake::Task['compile'].invoke 
     242    end 
     243    profiler.measure(:test) do 
     244      Rake::Task['test'].invoke 
     245    end 
     246    profiler.ext_size(ext_so) 
     247     
     248  end 
     249  puts RagelProfiler.results 
     250end 
  • trunk/ext/redcloth_scan/extconf.rb

    r274 r300  
    33$CFLAGS << " -O0 " # do not optimize (takes too much memory and performance gain is negligeable) 
    44 
    5 dir_config("redcloth_scan") 
    6 have_library("c", "main") 
     5### It seems to work fine without these 
     6# dir_config("redcloth_scan") 
     7# have_library("c", "main") 
    78 
    89create_makefile("redcloth_scan")