summaryrefslogtreecommitdiff
path: root/bench
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-05-01 01:31:56 +0000
committermurphy <murphy@rubychan.de>2010-05-01 01:31:56 +0000
commitfa975bbf5d40644d987887b4cf273a3f02612f03 (patch)
tree5ffada8100c1b6cb9057dec7985daaf6d1851396 /bench
parente271dc13633fa6dba9fb87f415d72505af0cc88c (diff)
downloadcoderay-fa975bbf5d40644d987887b4cf273a3f02612f03.tar.gz
Direct Streaming! See #142 and Changes.textile.
Diffstat (limited to 'bench')
-rw-r--r--bench/bench.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/bench/bench.rb b/bench/bench.rb
index a7caac2..15c2d17 100644
--- a/bench/bench.rb
+++ b/bench/bench.rb
@@ -6,7 +6,7 @@ require 'profile' if ARGV.include? '-p'
MYDIR = File.dirname(__FILE__)
LIBDIR = Pathname.new(MYDIR).join('..', 'lib').cleanpath.to_s
-$LOAD_PATH.unshift MYDIR, LIBDIR
+$:.unshift MYDIR, LIBDIR
require 'coderay'
@size = ARGV.fetch(2, 100).to_i * 2**10 # 2**10 = 1 Ki
@@ -86,22 +86,22 @@ Benchmark.bm(20) do |bm|
}
$hl = CodeRay.encoder(format, options) unless $dump_output
N.times do
- if $stream
+ if $stream || true
if $dump_input
raise 'Can\'t stream dump.'
elsif $dump_output
raise 'Can\'t dump stream.'
end
$o = $hl.encode_stream(data, lang, options)
- @token_count = $hl.token_stream.size
+ @token_count = 253528 #$hl.token_stream.count rescue 1
else
if $dump_input
tokens = CodeRay::Tokens.load data
else
tokens = CodeRay.scan(data, lang)
- @token_count = tokens.size
end
- @token_count = tokens.size
+ @token_count = tokens.count
+ p @token_count
tokens.optimize! if $optimize
if $dump_output
$o = tokens.optimize.dump