Sha256: f47e874aebb4bf8107d0068a863c8b97fc0dab1c48ec43c594703e8b17d63ca6

Contents?: true

Size: 991 Bytes

Versions: 1

Compression:

Stored size: 991 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))

class BenchmarkTest < Test::Unit::TestCase

  require 'benchmark'
  
  def setup
  @example_sexp = <<-EOD
      [display "This is a test string!"]
      
      [define test [lambda [] [begin
        [display [== 1 1]]
        [display [== true true]]
        [display [== false false]]
        [display [== nil nil]]
        [display [== 2.09 1.08]]
        [display [== 2e6 2e12]]
      ]]]
    EOD
  end

  test "benchmark sexpistol's bracer" do
    puts "\nRunning performance test...\n"
    
    parser = Bracer.new
    parser.ruby_keyword_literals = true
    
    Benchmark.bmbm do |b|
      b.report("Parse") do
        5000.times do
          parser.parse_string(@example_sexp)
        end
      end
      
      b.report("to_sexp") do
        ast = parser.parse_string(@example_sexp)
        5000.times do
          parser.to_sexp(ast)
        end
      end
    end
    
    puts
  end    
    
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bracer-0.0.2 test/performance/benchmark_test.rb