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
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/fast_cov/benchmark/scenarios.rb', line 6
def self.register(runner, fixtures_dir:)
root_calculator = File.join(fixtures_dir, "calculator")
root_all = fixtures_dir
ignored_path = File.join(fixtures_dir, "vendor")
calculator = Calculator.new
runner.scenario("Line coverage (small)") do
cov = FastCov::Coverage.new(root: root_calculator)
cov.start
calculator.add(1, 2)
calculator.subtract(3, 1)
cov.stop
end
runner.scenario("Line coverage (many files)") do
cov = FastCov::Coverage.new(root: root_all)
cov.start
calculator.add(1, 2)
calculator.subtract(3, 1)
calculator.multiply(2, 3)
calculator.divide(6, 2)
ConstantReader.new.operations
MyModel.new
User.new("test", "test@test.com")
DynamicModel.new.some_method
cov.stop
end
runner.scenario("Line coverage (single-threaded)") do
cov = FastCov::Coverage.new(root: root_calculator, threads: false)
cov.start
calculator.add(1, 2)
calculator.subtract(3, 1)
cov.stop
end
runner.scenario("Line coverage (with ignored_path)") do
cov = FastCov::Coverage.new(root: root_all, ignored_paths: [ignored_path])
cov.start
calculator.add(1, 2)
calculator.subtract(3, 1)
cov.stop
end
runner.scenario("Rapid start/stop (100x)") do
cov = FastCov::Coverage.new(root: root_calculator)
100.times do
cov.start
calculator.add(1, 2)
cov.stop
end
end
runner.scenario("Multi-threaded coverage") do
cov = FastCov::Coverage.new(root: root_calculator)
cov.start
t = Thread.new { calculator.add(1, 2) }
calculator.multiply(2, 3)
t.join
cov.stop
end
end
|