test-prof 0.1.0.pre5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +16 -4
- data/assets/flamegraph.demo.html +173 -0
- data/assets/flamegraph.template.html +196 -0
- data/assets/src/d3-tip.js +352 -0
- data/assets/src/d3-tip.min.js +1 -0
- data/assets/src/d3.flameGraph.css +92 -0
- data/assets/src/d3.flameGraph.js +459 -0
- data/assets/src/d3.flameGraph.min.css +1 -0
- data/assets/src/d3.flameGraph.min.js +1 -0
- data/assets/src/d3.v4.min.js +8 -0
- data/guides/any_fixture.md +1 -1
- data/guides/event_prof.md +30 -0
- data/guides/factory_default.md +109 -0
- data/guides/factory_prof.md +85 -0
- data/guides/rubocop.md +48 -0
- data/guides/ruby_prof.md +2 -0
- data/guides/stack_prof.md +5 -1
- data/guides/tag_prof.md +52 -0
- data/guides/tests_sampling.md +24 -0
- data/lib/test_prof.rb +31 -7
- data/lib/test_prof/cops/rspec/aggregate_failures.rb +140 -0
- data/lib/test_prof/event_prof/custom_events.rb +3 -3
- data/lib/test_prof/event_prof/custom_events/factory_create.rb +10 -8
- data/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb +10 -8
- data/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb +12 -10
- data/lib/test_prof/event_prof/rspec.rb +5 -1
- data/lib/test_prof/factory_default.rb +58 -0
- data/lib/test_prof/factory_default/factory_girl_patch.rb +22 -0
- data/lib/test_prof/factory_doctor.rb +11 -9
- data/lib/test_prof/factory_doctor/rspec.rb +5 -3
- data/lib/test_prof/factory_prof.rb +140 -0
- data/lib/test_prof/factory_prof/factory_girl_patch.rb +12 -0
- data/lib/test_prof/factory_prof/printers/flamegraph.rb +71 -0
- data/lib/test_prof/factory_prof/printers/simple.rb +28 -0
- data/lib/test_prof/recipes/minitest/sample.rb +29 -0
- data/lib/test_prof/recipes/rspec/factory_default.rb +9 -0
- data/lib/test_prof/recipes/rspec/sample.rb +13 -0
- data/lib/test_prof/rspec_stamp/rspec.rb +5 -1
- data/lib/test_prof/rubocop.rb +3 -0
- data/lib/test_prof/ruby_prof.rb +6 -12
- data/lib/test_prof/stack_prof.rb +14 -7
- data/lib/test_prof/tag_prof.rb +8 -0
- data/lib/test_prof/tag_prof/rspec.rb +84 -0
- data/lib/test_prof/version.rb +1 -1
- metadata +48 -41
- data/.gitignore +0 -10
- data/.rspec +0 -2
- data/.rubocop.yml +0 -69
- data/.travis.yml +0 -5
- data/Gemfile +0 -4
- data/Rakefile +0 -8
- data/bin/setup +0 -8
- data/circle.yml +0 -11
- data/spec/integrations/any_fixture_spec.rb +0 -11
- data/spec/integrations/before_all_spec.rb +0 -11
- data/spec/integrations/event_prof_spec.rb +0 -100
- data/spec/integrations/factory_doctor_spec.rb +0 -20
- data/spec/integrations/fixtures/rspec/any_fixture_fixture.rb +0 -37
- data/spec/integrations/fixtures/rspec/before_all_fixture.rb +0 -32
- data/spec/integrations/fixtures/rspec/event_prof_factory_create_fixture.rb +0 -23
- data/spec/integrations/fixtures/rspec/event_prof_fixture.rb +0 -51
- data/spec/integrations/fixtures/rspec/event_prof_sidekiq_fixture.rb +0 -53
- data/spec/integrations/fixtures/rspec/factory_doctor_fixture.rb +0 -33
- data/spec/integrations/fixtures/rspec/rspec_stamp_fixture_tmpl.rb +0 -33
- data/spec/integrations/rspec_stamp_spec.rb +0 -53
- data/spec/spec_helper.rb +0 -38
- data/spec/support/ar_models.rb +0 -43
- data/spec/support/instrumenter_stub.rb +0 -19
- data/spec/support/integration_helpers.rb +0 -13
- data/spec/support/transactional_context.rb +0 -11
- data/spec/test_prof/any_fixture_spec.rb +0 -66
- data/spec/test_prof/event_prof_spec.rb +0 -138
- data/spec/test_prof/ext/float_duration_spec.rb +0 -12
- data/spec/test_prof/factory_doctor_spec.rb +0 -84
- data/spec/test_prof/rspec_stamp/parser_spec.rb +0 -58
- data/spec/test_prof/rspec_stamp_spec.rb +0 -281
- data/spec/test_prof/ruby_prof_spec.rb +0 -109
- data/spec/test_prof/stack_prof_spec.rb +0 -73
- data/spec/test_prof_spec.rb +0 -23
- data/test-prof.gemspec +0 -35
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
Include:
|
3
|
-
- 'lib/**/*.rb'
|
4
|
-
- 'lib/**/*.rake'
|
5
|
-
- 'spec/**/*.rb'
|
6
|
-
Exclude:
|
7
|
-
- 'bin/**/*'
|
8
|
-
- 'spec/dummy/**/*'
|
9
|
-
- 'tmp/**/*'
|
10
|
-
- 'Rakefile'
|
11
|
-
- 'Gemfile'
|
12
|
-
- '*.gemspec'
|
13
|
-
DisplayCopNames: true
|
14
|
-
StyleGuideCopsOnly: false
|
15
|
-
TargetRubyVersion: 2.3
|
16
|
-
|
17
|
-
Rails:
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
Style/AccessorMethodName:
|
21
|
-
Enabled: false
|
22
|
-
|
23
|
-
Style/TrivialAccessors:
|
24
|
-
Enabled: false
|
25
|
-
|
26
|
-
Style/Documentation:
|
27
|
-
Exclude:
|
28
|
-
- 'spec/**/*.rb'
|
29
|
-
|
30
|
-
Style/StringLiterals:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
Style/RegexpLiteral:
|
34
|
-
Enabled: false
|
35
|
-
|
36
|
-
Style/SpaceInsideStringInterpolation:
|
37
|
-
EnforcedStyle: no_space
|
38
|
-
|
39
|
-
Style/ClassAndModuleChildren:
|
40
|
-
Enabled: false
|
41
|
-
|
42
|
-
Style/BlockDelimiters:
|
43
|
-
Exclude:
|
44
|
-
- 'spec/**/*.rb'
|
45
|
-
|
46
|
-
Lint/AmbiguousRegexpLiteral:
|
47
|
-
Enabled: false
|
48
|
-
|
49
|
-
|
50
|
-
Metrics/MethodLength:
|
51
|
-
Enabled: false
|
52
|
-
|
53
|
-
Metrics/AbcSize:
|
54
|
-
Enabled: false
|
55
|
-
|
56
|
-
Metrics/LineLength:
|
57
|
-
Max: 100
|
58
|
-
Exclude:
|
59
|
-
- 'spec/**/*.rb'
|
60
|
-
|
61
|
-
Metrics/BlockLength:
|
62
|
-
Exclude:
|
63
|
-
- 'spec/**/*.rb'
|
64
|
-
|
65
|
-
Rails/Date:
|
66
|
-
Enabled: false
|
67
|
-
|
68
|
-
Rails/TimeZone:
|
69
|
-
Enabled: false
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bin/setup
DELETED
data/circle.yml
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe "EventProf" do
|
6
|
-
specify "RSpec integration", :aggregate_failures do
|
7
|
-
output = run_rspec('event_prof', env: { 'EVENT_PROF' => 'test.event' })
|
8
|
-
|
9
|
-
expect(output).to include("EventProf results for test.event")
|
10
|
-
expect(output).to match(/Total time: 25:56\.\d{3}/)
|
11
|
-
expect(output).to include("Total events: 8")
|
12
|
-
|
13
|
-
expect(output).to include("Top 5 slowest suites (by time):")
|
14
|
-
expect(output).to include("Top 5 slowest tests (by time):")
|
15
|
-
|
16
|
-
expect(output).to include(
|
17
|
-
"Another something (./event_prof_fixture.rb:42) – 16:40.000 (1 / 2)\n"\
|
18
|
-
"Something (./event_prof_fixture.rb:21) – 09:16.100 (7 / 3)"
|
19
|
-
)
|
20
|
-
|
21
|
-
expect(output).to include(
|
22
|
-
"do very long (./event_prof_fixture.rb:47) – 16:40.000 (1)\n"\
|
23
|
-
"invokes twice (./event_prof_fixture.rb:27) – 06:20.000 (2)\n"\
|
24
|
-
"invokes many times (./event_prof_fixture.rb:33) – 02:16.000 (4)\n"\
|
25
|
-
"invokes once (./event_prof_fixture.rb:22) – 00:40.100 (1)"
|
26
|
-
)
|
27
|
-
end
|
28
|
-
|
29
|
-
specify "RSpec integration with rank by count", :aggregate_failures do
|
30
|
-
output = run_rspec(
|
31
|
-
'event_prof',
|
32
|
-
env: { 'EVENT_PROF' => 'test.event', 'EVENT_PROF_RANK' => 'count' }
|
33
|
-
)
|
34
|
-
|
35
|
-
expect(output).to include("EventProf results for test.event")
|
36
|
-
expect(output).to match(/Total time: 25:56\.\d{3}/)
|
37
|
-
expect(output).to include("Total events: 8")
|
38
|
-
|
39
|
-
expect(output).to include("Top 5 slowest suites (by count):")
|
40
|
-
expect(output).to include("Top 5 slowest tests (by count):")
|
41
|
-
|
42
|
-
expect(output).to include(
|
43
|
-
"Something (./event_prof_fixture.rb:21) – 09:16.100 (7 / 3)\n"\
|
44
|
-
"Another something (./event_prof_fixture.rb:42) – 16:40.000 (1 / 2)"
|
45
|
-
)
|
46
|
-
|
47
|
-
expect(output).to include(
|
48
|
-
"invokes many times (./event_prof_fixture.rb:33) – 02:16.000 (4)\n"\
|
49
|
-
"invokes twice (./event_prof_fixture.rb:27) – 06:20.000 (2)\n"\
|
50
|
-
"invokes once (./event_prof_fixture.rb:22) – 00:40.100 (1)\n"\
|
51
|
-
"do very long (./event_prof_fixture.rb:47) – 16:40.000 (1)"
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
|
-
context "CustomEvents" do
|
56
|
-
it "works with factory.create" do
|
57
|
-
output = run_rspec(
|
58
|
-
'event_prof_factory_create',
|
59
|
-
env: { 'EVENT_PROF' => 'factory.create' }
|
60
|
-
)
|
61
|
-
|
62
|
-
expect(output).to include("EventProf results for factory.create")
|
63
|
-
expect(output).to match(/Total time: \d{2}:\d{2}\.\d{3}/)
|
64
|
-
expect(output).to include("Total events: 3")
|
65
|
-
|
66
|
-
expect(output).to match(%r{Post \(./event_prof_factory_create_fixture.rb:7\) – \d{2}:\d{2}.\d{3} \(2 / 1\)})
|
67
|
-
expect(output).to match(%r{User \(./event_prof_factory_create_fixture.rb:16\) – \d{2}:\d{2}.\d{3} \(1 / 1\)})
|
68
|
-
end
|
69
|
-
|
70
|
-
it "works with sidekiq.inline" do
|
71
|
-
output = run_rspec(
|
72
|
-
'event_prof_sidekiq',
|
73
|
-
env: { 'EVENT_PROF' => 'sidekiq.inline' }
|
74
|
-
)
|
75
|
-
|
76
|
-
expect(output).to include("EventProf results for sidekiq.inline")
|
77
|
-
expect(output).to match(/Total time: \d{2}:\d{2}\.\d{3}/)
|
78
|
-
expect(output).to include("Total events: 3")
|
79
|
-
|
80
|
-
expect(output).to match(%r{SingleJob \(./event_prof_sidekiq_fixture.rb:27\) – \d{2}:\d{2}.\d{3} \(2 / 2\)})
|
81
|
-
expect(output).to match(%r{BatchJob \(./event_prof_sidekiq_fixture.rb:39\) – \d{2}:\d{2}.\d{3} \(1 / 2\)})
|
82
|
-
end
|
83
|
-
|
84
|
-
it "works with sidekiq.jobs" do
|
85
|
-
output = run_rspec(
|
86
|
-
'event_prof_sidekiq',
|
87
|
-
env: { 'EVENT_PROF' => 'sidekiq.jobs' }
|
88
|
-
)
|
89
|
-
|
90
|
-
expect(output).to include("EventProf results for sidekiq.jobs")
|
91
|
-
expect(output).to match(/Total time: \d{2}:\d{2}\.\d{3}/)
|
92
|
-
expect(output).to include("Total events: 6")
|
93
|
-
|
94
|
-
expect(output).to include("Top 5 slowest suites (by count):")
|
95
|
-
|
96
|
-
expect(output).to match(%r{SingleJob \(./event_prof_sidekiq_fixture.rb:27\) – \d{2}:\d{2}.\d{3} \(2 / 2\)})
|
97
|
-
expect(output).to match(%r{BatchJob \(./event_prof_sidekiq_fixture.rb:39\) – \d{2}:\d{2}.\d{3} \(4 / 2\)})
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe "FactoryDoctor" do
|
6
|
-
specify "RSpec integration", :aggregate_failures do
|
7
|
-
output = run_rspec('factory_doctor', env: { 'FDOC' => '1' })
|
8
|
-
|
9
|
-
expect(output).to include("FactoryDoctor report")
|
10
|
-
expect(output).to include("Total (potentially) bad examples: 3")
|
11
|
-
expect(output).to match(/Total wasted time: \d{2}:\d{2}\.\d{3}/)
|
12
|
-
|
13
|
-
expect(output).to include("User (./factory_doctor_fixture.rb:7)")
|
14
|
-
expect(output).to include("generates random names (./factory_doctor_fixture.rb:10) – 2 records created")
|
15
|
-
expect(output).to include("validates name (./factory_doctor_fixture.rb:15) – 1 record created")
|
16
|
-
expect(output).to include("clones (./factory_doctor_fixture.rb:25) – 1 record created")
|
17
|
-
expect(output).not_to include("is ignored")
|
18
|
-
expect(output).not_to include("creates and reloads user")
|
19
|
-
end
|
20
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.expand_path("../../../../lib", __FILE__)
|
4
|
-
require_relative "../../../support/ar_models"
|
5
|
-
require_relative "../../../support/transactional_context"
|
6
|
-
require "test_prof/recipes/rspec/any_fixture"
|
7
|
-
|
8
|
-
shared_context "user", user: true do
|
9
|
-
before(:all) do
|
10
|
-
@user = TestProf::AnyFixture.register(:user) do
|
11
|
-
FactoryGirl.create(:user)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:user) { User.find(@user.id) }
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "User", :user do
|
19
|
-
it "creates user" do
|
20
|
-
user.name = ''
|
21
|
-
expect(user).not_to be_valid
|
22
|
-
end
|
23
|
-
|
24
|
-
context "with clean fixture", :transactional, :with_clean_fixture do
|
25
|
-
specify "no users" do
|
26
|
-
expect(User.count).to eq 0
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "Post", :user do
|
32
|
-
let(:post) { FactoryGirl.create(:post, user: user) }
|
33
|
-
|
34
|
-
it "creates post with the same user" do
|
35
|
-
expect { post }.not_to change(User, :count)
|
36
|
-
end
|
37
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.expand_path("../../../../lib", __FILE__)
|
4
|
-
require_relative "../../../support/ar_models"
|
5
|
-
require "test_prof/recipes/rspec/before_all"
|
6
|
-
|
7
|
-
describe "User" do
|
8
|
-
context "with before_all" do
|
9
|
-
before_all do
|
10
|
-
@user = FactoryGirl.create(:user)
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:user) { User.find(@user.id) }
|
14
|
-
|
15
|
-
it "validates name" do
|
16
|
-
user.name = ''
|
17
|
-
expect(user).not_to be_valid
|
18
|
-
end
|
19
|
-
|
20
|
-
it "clones" do
|
21
|
-
cloned = user.clone
|
22
|
-
cloned.save!
|
23
|
-
expect(cloned.reload.name).to include("(cloned)")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "without before_all" do
|
28
|
-
specify "no users" do
|
29
|
-
expect(User.count).to eq 0
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.expand_path("../../../../lib", __FILE__)
|
4
|
-
require_relative "../../../support/ar_models"
|
5
|
-
require "test-prof"
|
6
|
-
|
7
|
-
describe "Post" do
|
8
|
-
let(:user) { FactoryGirl.create(:user) }
|
9
|
-
|
10
|
-
it "generates random names" do
|
11
|
-
user2 = FactoryGirl.create(:post).user
|
12
|
-
expect(user.name).not_to eq user2.name
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "User" do
|
17
|
-
let(:user) { FactoryGirl.create(:user) }
|
18
|
-
|
19
|
-
it "validates name" do
|
20
|
-
user.name = ''
|
21
|
-
expect(user).not_to be_valid
|
22
|
-
end
|
23
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.expand_path("../../../../lib", __FILE__)
|
4
|
-
require "active_support"
|
5
|
-
require "test-prof"
|
6
|
-
|
7
|
-
TestProf::EventProf.configure do |config|
|
8
|
-
config.per_example = true
|
9
|
-
end
|
10
|
-
|
11
|
-
module Instrumenter
|
12
|
-
def self.notify(_event, time)
|
13
|
-
ActiveSupport::Notifications.publish(
|
14
|
-
'test.event',
|
15
|
-
0,
|
16
|
-
time
|
17
|
-
)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "Something" do
|
22
|
-
it "invokes once" do
|
23
|
-
Instrumenter.notify 'test.event', 40.1
|
24
|
-
expect(true).to eq true
|
25
|
-
end
|
26
|
-
|
27
|
-
it "invokes twice" do
|
28
|
-
Instrumenter.notify 'test.event', 140
|
29
|
-
Instrumenter.notify 'test.event', 240
|
30
|
-
expect(true).to eq true
|
31
|
-
end
|
32
|
-
|
33
|
-
it "invokes many times" do
|
34
|
-
Instrumenter.notify 'test.event', 14
|
35
|
-
Instrumenter.notify 'test.event', 40
|
36
|
-
Instrumenter.notify 'test.event', 42
|
37
|
-
Instrumenter.notify 'test.event', 40
|
38
|
-
expect(true).to eq true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "Another something" do
|
43
|
-
it "do nothing" do
|
44
|
-
expect(true).to eq true
|
45
|
-
end
|
46
|
-
|
47
|
-
it "do very long" do
|
48
|
-
Instrumenter.notify 'test.event', 1000
|
49
|
-
expect(true).to eq true
|
50
|
-
end
|
51
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
$LOAD_PATH.unshift File.expand_path("../../../../lib", __FILE__)
|
4
|
-
require "active_support"
|
5
|
-
require "sidekiq/testing"
|
6
|
-
|
7
|
-
Sidekiq::Testing.inline!
|
8
|
-
|
9
|
-
class SingleJob
|
10
|
-
include Sidekiq::Worker
|
11
|
-
|
12
|
-
def perform(*_args)
|
13
|
-
true
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class BatchJob
|
18
|
-
include Sidekiq::Worker
|
19
|
-
|
20
|
-
def perform(count)
|
21
|
-
count.times { SingleJob.perform_async(true) }
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
require "test-prof"
|
26
|
-
|
27
|
-
describe "SingleJob" do
|
28
|
-
it "invokes once" do
|
29
|
-
SingleJob.perform_async(1)
|
30
|
-
expect(true).to eq true
|
31
|
-
end
|
32
|
-
|
33
|
-
it "invokes twice" do
|
34
|
-
SingleJob.perform_async(2)
|
35
|
-
expect(true).to eq true
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "BatchJob" do
|
40
|
-
it "invokes nested" do
|
41
|
-
BatchJob.perform_async(3)
|
42
|
-
expect(true).to eq true
|
43
|
-
end
|
44
|
-
|
45
|
-
context "when fake" do
|
46
|
-
it "is fake" do
|
47
|
-
Sidekiq::Testing.fake! do
|
48
|
-
BatchJob.perform_async(3)
|
49
|
-
end
|
50
|
-
expect(true).to eq true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|