-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Smith
committed
Jun 17, 2013
1 parent
80bdc9b
commit 31521dc
Showing
1 changed file
with
32 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,38 @@ | ||
require File.expand_path("../helper.rb", __FILE__) | ||
|
||
class BenchmarkTest < QCTest | ||
|
||
def test_enqueue | ||
n = 10_000 | ||
start = Time.now | ||
n.times do | ||
QC.enqueue("1.odd?", []) | ||
end | ||
assert_equal(n, QC.count) | ||
|
||
elapsed = Time.now - start | ||
assert_in_delta(4, elapsed, 1) | ||
end | ||
|
||
def test_dequeue | ||
worker = QC::Worker.new | ||
worker.running = true | ||
n = 10_000 | ||
n.times do | ||
QC.enqueue("1.odd?", []) | ||
if ENV["QC_BENCHMARK"] | ||
class BenchmarkTest < QCTest | ||
|
||
def test_enqueue | ||
n = 10_000 | ||
start = Time.now | ||
n.times do | ||
QC.enqueue("1.odd?", []) | ||
end | ||
assert_equal(n, QC.count) | ||
|
||
elapsed = Time.now - start | ||
assert_in_delta(4, elapsed, 1) | ||
end | ||
assert_equal(n, QC.count) | ||
|
||
start = Time.now | ||
n.times do | ||
worker.work | ||
|
||
def test_dequeue | ||
worker = QC::Worker.new | ||
worker.running = true | ||
n = 10_000 | ||
n.times do | ||
QC.enqueue("1.odd?", []) | ||
end | ||
assert_equal(n, QC.count) | ||
|
||
start = Time.now | ||
n.times do | ||
worker.work | ||
end | ||
elapsed = Time.now - start | ||
|
||
assert_equal(0, QC.count) | ||
assert_in_delta(10, elapsed, 3) | ||
end | ||
elapsed = Time.now - start | ||
|
||
assert_equal(0, QC.count) | ||
assert_in_delta(10, elapsed, 3) | ||
|
||
end | ||
|
||
end |