forked from hardcode-dev/rails-optimization-task1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
task-1_spec.rb
57 lines (50 loc) · 1.78 KB
/
task-1_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'rspec-benchmark'
require_relative 'task-1'
RSpec.configure do |config|
config.include RSpec::Benchmark::Matchers
end
describe 'Perfomance with disable garbage collection' do
describe 'load simple data.txt file' do
it 'should works under 1 ms' do
expect {
work('fixtures/data.txt', disable_gc = false)
}.to perform_under(10).ms.warmup(2).times.sample(10).times
end
end
describe 'load large size file data_10000.txt with 1_000 lines and turn off garbage collection' do
it 'should works under 0.02 s' do
expect {
work('fixtures/data_1000.txt', disable_gc = false)
}.to perform_under(5).ms.warmup(2).times.sample(10).times
end
end
describe 'load large size file data_10000.txt with 10_000 lines and turn off garbage collection' do
it 'should works under 0.8 s' do
expect {
work('fixtures/data_10000.txt', disable_gc = false)
}.to perform_under(100).ms.warmup(2).times.sample(10).times
end
end
describe 'load large size file data_30000.txt with 20_000 lines and turn off garbage collection' do
it 'should works under 26,9 s' do
expect {
work('fixtures/data_30000.txt', disable_gc = false)
}.to perform_under(600).ms.warmup(2).times.sample(10).times
end
end
#
# describe 'load large size file data_100000.txt with 10_000 lines' do
# it 'should works under 8 s' do
# expect {
# work('data_100000.txt')
# }.to perform_under(2000).ms.warmup(2).times.sample(10).times
# end
# end
describe 'load large size file data_large.txt' do
it 'should works under 35 s' do
expect {
work('fixtures/data_large.txt', disable_gc = false)
}.to perform_under(35000).ms.warmup(2).times.sample(10).times
end
end
end