diff options
-rw-r--r-- | .travis.yml | 15 | ||||
-rw-r--r-- | Gemfile | 10 | ||||
-rw-r--r-- | bench/bench.rb | 10 | ||||
-rw-r--r-- | rake_tasks/benchmark.rake | 2 |
4 files changed, 19 insertions, 18 deletions
diff --git a/.travis.yml b/.travis.yml index a8080ce..75a57bb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,21 +8,18 @@ rvm: - 2.0 - 2.1 - 2.2 - - 2.3.0 + - 2.3.3 + - 2.4.0 - ruby-head - - jruby-18mode - - jruby-19mode - - jruby-head - - rbx-2 + - jruby + - rbx branches: only: - master matrix: allow_failures: - rvm: ruby-head - - rvm: jruby-18mode - - rvm: jruby-19mode - - rvm: jruby-head - - rvm: rbx-2 + - rvm: jruby + - rvm: rbx script: "rake test" # test:scanners" sudo: false @@ -8,11 +8,11 @@ gemspec group :development do gem "bundler" gem "rake", "~> 10.5" - gem "RedCloth", RUBY_PLATFORM == 'java' ? ">= 4.2.7" : ">= 4.0.3" - gem "term-ansicolor" + gem "RedCloth", RUBY_PLATFORM == 'java' ? "= 4.2.9" : ">= 4.0.3" + gem "term-ansicolor", "~> 1.3.2" gem 'tins', '~> 1.6.0' - gem "shoulda-context" + gem "shoulda-context", "= 1.2.1" gem "test-unit" - gem "json" if RUBY_VERSION < '1.9' - gem "rdoc" + gem "json", "~> 1.8" if RUBY_VERSION < '1.9' + gem "rdoc", "~> 4.2.2" end diff --git a/bench/bench.rb b/bench/bench.rb index 92f9d07..34ea9f9 100644 --- a/bench/bench.rb +++ b/bench/bench.rb @@ -15,7 +15,7 @@ raise 'Example file is empty.' if data.empty? format = ARGV.fetch(1, 'html').downcase encoder = CodeRay.encoder(format) -size = ARGV.fetch(2, 1000).to_i * 1000 +size = ARGV.fetch(2, 2000).to_i * 1000 unless size.zero? data += data until data.size >= size data = data[0, size] @@ -23,14 +23,18 @@ end size = data.size puts "encoding %d kB of #{lang} code to #{format}..." % [(size / 1000.0).round] -n = ARGV.fetch(3, 5).to_s[/\d+/].to_i +n = ARGV.fetch(3, 10).to_s[/\d+/].to_i require 'profile' if ARGV.include? '-p' +times = [] n.times do |i| time = Benchmark.realtime { encoder.encode(data, lang) } puts "run %d: %5.2f s, %4.0f kB/s" % [i + 1, time, size / time / 1000.0] + times << time end -STDIN.gets if ARGV.include? '-w' +times_sum = times.inject(0) { |time, sum| sum + time } +puts 'Average time: %5.2f s, %4.0f kB/s' % [times_sum / times.size, (size * n) / times_sum / 1000.0] +puts 'Best time: %5.2f s, %4.0f kB/s' % [times.min, size / times.min / 1000.0] __END__ Usage: diff --git a/rake_tasks/benchmark.rake b/rake_tasks/benchmark.rake index 2e38b57..8edeffb 100644 --- a/rake_tasks/benchmark.rake +++ b/rake_tasks/benchmark.rake @@ -1,6 +1,6 @@ desc 'Do a benchmark' task :benchmark do - ruby 'bench/bench.rb ruby html 3000' + ruby 'bench/bench.rb ruby html' end task :bench => :benchmark |