Skip to content

Commit

Permalink
[tests] update to tests/benches
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ Christensen committed Aug 17, 2012
1 parent d8e059e commit e1b2500
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions Rakefile
@@ -1,3 +1,4 @@
require 'bundler/setup'
require 'rake/testtask'

Rake::TestTask.new do |t|
Expand Down
19 changes: 19 additions & 0 deletions bin/sieve
@@ -0,0 +1,19 @@
#!/usr/bin/env ruby
# -*- mode: ruby -*-

require 'rubygems'
require 'bundler/setup'
require_relative '../lib/sieve/primes'

require 'benchmark'

# require 'minitest/autorun'
# require 'minitest/benchmark'

input = ARGV.first.to_i

primes = Sieve::Primes.new

Benchmark.bm do |x|
x.report("#{input} primes (sieve):") { primes.take(input) }
end
1 change: 1 addition & 0 deletions lib/sieve/controller.rb
@@ -1,5 +1,6 @@
require 'celluloid'
require_relative "candidates"
require_relative "model"

module Sieve
class Controller
Expand Down
2 changes: 1 addition & 1 deletion test/sieve/model_test.rb
Expand Up @@ -2,7 +2,7 @@

require 'sieve/model'

class ModelTest < MiniTest::Unit::TestCase
class TestModels < MiniTest::Unit::TestCase

# Empty models shouldn't match anything
def test_model_empty
Expand Down
12 changes: 11 additions & 1 deletion test/sieve/primes_test.rb
@@ -1,8 +1,18 @@
require 'minitest/autorun'
require 'minitest/benchmark'
require 'prime'
require 'sieve/primes'

class PrimesTest < MiniTest::Unit::TestCase
class TestPrimes < MiniTest::Unit::TestCase
def self.bench_range
[1_000, 10_000, 100_000, 1_000_000]
end

def bench_sieve_primes
assert_performance_linear 0.9977 do |n|
Sieve::Primes.new.take(n)[4,-1]
end
end

# Verify that we can at least obtain the seeded values from the controller
def test_controller_seeds_only
Expand Down

0 comments on commit e1b2500

Please sign in to comment.