test-prof 0.1.0.beta4 → 0.1.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.rubocop.yml +69 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +2 -16
- data/Rakefile +8 -0
- data/bin/setup +8 -0
- data/circle.yml +11 -0
- data/guides/any_fixture.md +1 -1
- data/guides/ruby_prof.md +0 -2
- data/guides/stack_prof.md +1 -5
- data/lib/test_prof.rb +6 -31
- data/lib/test_prof/event_prof.rb +4 -2
- data/lib/test_prof/event_prof/custom_events.rb +3 -3
- data/lib/test_prof/event_prof/custom_events/factory_create.rb +9 -11
- data/lib/test_prof/event_prof/custom_events/sidekiq_inline.rb +9 -11
- data/lib/test_prof/event_prof/custom_events/sidekiq_jobs.rb +11 -13
- data/lib/test_prof/event_prof/rspec.rb +1 -5
- data/lib/test_prof/factory_doctor.rb +9 -11
- data/lib/test_prof/factory_doctor/rspec.rb +3 -5
- data/lib/test_prof/ruby_prof.rb +12 -6
- data/lib/test_prof/stack_prof.rb +7 -14
- data/lib/test_prof/version.rb +1 -1
- data/spec/integrations/any_fixture_spec.rb +11 -0
- data/spec/integrations/before_all_spec.rb +11 -0
- data/spec/integrations/event_prof_spec.rb +100 -0
- data/spec/integrations/factory_doctor_spec.rb +20 -0
- data/spec/integrations/fixtures/rspec/any_fixture_fixture.rb +37 -0
- data/spec/integrations/fixtures/rspec/before_all_fixture.rb +32 -0
- data/spec/integrations/fixtures/rspec/event_prof_factory_create_fixture.rb +23 -0
- data/spec/integrations/fixtures/rspec/event_prof_fixture.rb +51 -0
- data/spec/integrations/fixtures/rspec/event_prof_sidekiq_fixture.rb +54 -0
- data/spec/integrations/fixtures/rspec/factory_doctor_fixture.rb +33 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/ar_models.rb +43 -0
- data/spec/support/instrumenter_stub.rb +19 -0
- data/spec/support/integration_helpers.rb +13 -0
- data/spec/support/transactional_context.rb +11 -0
- data/spec/test_prof/any_fixture_spec.rb +66 -0
- data/spec/test_prof/event_prof_spec.rb +138 -0
- data/spec/test_prof/ext/float_duration_spec.rb +12 -0
- data/spec/test_prof/factory_doctor_spec.rb +84 -0
- data/spec/test_prof/ruby_prof_spec.rb +109 -0
- data/spec/test_prof/stack_prof_spec.rb +73 -0
- data/spec/test_prof_spec.rb +23 -0
- data/test-prof.gemspec +35 -0
- metadata +34 -49
- data/CHANGELOG.md +0 -7
- data/assets/flamegraph.demo.html +0 -173
- data/assets/flamegraph.template.html +0 -196
- data/assets/src/d3-tip.js +0 -352
- data/assets/src/d3-tip.min.js +0 -1
- data/assets/src/d3.flameGraph.css +0 -92
- data/assets/src/d3.flameGraph.js +0 -459
- data/assets/src/d3.flameGraph.min.css +0 -1
- data/assets/src/d3.flameGraph.min.js +0 -1
- data/assets/src/d3.v4.min.js +0 -8
- data/guides/factory_default.md +0 -109
- data/guides/factory_prof.md +0 -85
- data/guides/rspec_stamp.md +0 -53
- data/guides/rubocop.md +0 -48
- data/guides/tag_prof.md +0 -52
- data/guides/tests_sampling.md +0 -24
- data/lib/test_prof/cops/rspec/aggregate_failures.rb +0 -140
- data/lib/test_prof/factory_default.rb +0 -58
- data/lib/test_prof/factory_default/factory_girl_patch.rb +0 -22
- data/lib/test_prof/factory_prof.rb +0 -140
- data/lib/test_prof/factory_prof/factory_girl_patch.rb +0 -12
- data/lib/test_prof/factory_prof/printers/flamegraph.rb +0 -71
- data/lib/test_prof/factory_prof/printers/simple.rb +0 -28
- data/lib/test_prof/recipes/minitest/sample.rb +0 -29
- data/lib/test_prof/recipes/rspec/factory_default.rb +0 -9
- data/lib/test_prof/recipes/rspec/sample.rb +0 -13
- data/lib/test_prof/rspec_stamp.rb +0 -135
- data/lib/test_prof/rspec_stamp/parser.rb +0 -103
- data/lib/test_prof/rspec_stamp/rspec.rb +0 -95
- data/lib/test_prof/rubocop.rb +0 -3
- data/lib/test_prof/tag_prof.rb +0 -8
- data/lib/test_prof/tag_prof/rspec.rb +0 -84
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe TestProf::RubyProf do
|
6
|
+
# Use fresh config all for every example
|
7
|
+
after { described_class.remove_instance_variable(:@config) }
|
8
|
+
|
9
|
+
describe ".config" do
|
10
|
+
subject { described_class.config }
|
11
|
+
|
12
|
+
specify "defaults", :aggregate_failiures do
|
13
|
+
expect(subject.printer).to eq :call_stack
|
14
|
+
expect(subject.mode).to eq :wall
|
15
|
+
expect(subject.min_percent).to eq 1
|
16
|
+
expect(subject.include_threads).to eq false
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#resolve_printer" do
|
20
|
+
it "works with custom class" do
|
21
|
+
subject.printer = TestProf
|
22
|
+
expect(subject.resolve_printer).to eq(['custom', TestProf])
|
23
|
+
end
|
24
|
+
|
25
|
+
it "raises when unknown printer" do
|
26
|
+
subject.printer = 'unknown'
|
27
|
+
expect { subject.resolve_printer }.to raise_error(ArgumentError)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#profile" do
|
33
|
+
let(:ruby_prof) { double("ruby_prof") }
|
34
|
+
let(:profile) { double("profile") }
|
35
|
+
|
36
|
+
before do
|
37
|
+
stub_const("RubyProf::Profile", ruby_prof)
|
38
|
+
expect(profile).to receive(:start)
|
39
|
+
end
|
40
|
+
|
41
|
+
specify "with default config" do
|
42
|
+
expect(ruby_prof).to receive(:new).with(
|
43
|
+
merge_fibers: true,
|
44
|
+
include_threads: [Thread.current]
|
45
|
+
).and_return(profile)
|
46
|
+
|
47
|
+
expect(described_class.profile).to be_a(described_class::Report)
|
48
|
+
end
|
49
|
+
|
50
|
+
specify "with custom config" do
|
51
|
+
described_class.config.include_threads = true
|
52
|
+
|
53
|
+
expect(ruby_prof).to receive(:new).with(
|
54
|
+
merge_fibers: true
|
55
|
+
).and_return(profile)
|
56
|
+
|
57
|
+
described_class.profile
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "Report#dump" do
|
62
|
+
let(:ruby_prof) { double("ruby_prof") }
|
63
|
+
let(:profile) { double("profile") }
|
64
|
+
let(:result) { double("result") }
|
65
|
+
let(:printer_class) { double("printer_class") }
|
66
|
+
let(:printer) { double("printer") }
|
67
|
+
|
68
|
+
before do
|
69
|
+
stub_const("::RubyProf::Profile", ruby_prof)
|
70
|
+
expect(ruby_prof).to receive(:new).and_return(profile)
|
71
|
+
expect(profile).to receive(:start)
|
72
|
+
expect(profile).to receive(:stop).and_return(result)
|
73
|
+
end
|
74
|
+
|
75
|
+
subject { described_class.profile }
|
76
|
+
|
77
|
+
specify "with default config" do
|
78
|
+
expect(result).to receive(:eliminate_methods!)
|
79
|
+
|
80
|
+
stub_const("::RubyProf::CallStackPrinter", printer_class)
|
81
|
+
expect(printer_class).to receive(:new).with(result).and_return(printer)
|
82
|
+
expect(printer).to receive(:print).with(anything, min_percent: 1).and_return("")
|
83
|
+
|
84
|
+
subject.dump("stub")
|
85
|
+
|
86
|
+
expect(File.exist?("tmp/ruby-prof-report-call_stack-wall-stub.html")).to eq true
|
87
|
+
end
|
88
|
+
|
89
|
+
specify "with custom config" do
|
90
|
+
described_class.config.printer = :flat
|
91
|
+
described_class.config.eliminate_methods = []
|
92
|
+
described_class.config.min_percent = 2
|
93
|
+
described_class.config.mode = :cpu
|
94
|
+
|
95
|
+
TestProf.config.timestamps = true
|
96
|
+
|
97
|
+
expect(result).not_to receive(:eliminate_methods!)
|
98
|
+
|
99
|
+
stub_const("RubyProf::FlatPrinter", printer_class)
|
100
|
+
expect(printer_class).to receive(:new).with(result).and_return(printer)
|
101
|
+
expect(printer).to receive(:print).with(anything, min_percent: 2).and_return("")
|
102
|
+
expect(Time).to receive(:now).and_return(double("now", to_i: 123_454_321))
|
103
|
+
|
104
|
+
subject.dump("stub")
|
105
|
+
|
106
|
+
expect(File.exist?("tmp/ruby-prof-report-flat-cpu-stub-123454321.html")).to eq true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe TestProf::StackProf do
|
6
|
+
# Use fresh config all for every example
|
7
|
+
after { described_class.remove_instance_variable(:@config) }
|
8
|
+
|
9
|
+
describe ".config" do
|
10
|
+
subject { described_class.config }
|
11
|
+
|
12
|
+
specify "defaults", :aggregate_failiures do
|
13
|
+
expect(subject.mode).to eq :wall
|
14
|
+
expect(subject.interval).to be_nil
|
15
|
+
expect(subject.raw).to eq false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#profile" do
|
20
|
+
let(:stack_prof) { double("stack_prof") }
|
21
|
+
|
22
|
+
before do
|
23
|
+
stub_const("StackProf", stack_prof)
|
24
|
+
end
|
25
|
+
|
26
|
+
specify "with default config" do
|
27
|
+
expect(stack_prof).to receive(:start).with(
|
28
|
+
mode: :wall,
|
29
|
+
raw: false
|
30
|
+
)
|
31
|
+
|
32
|
+
described_class.profile
|
33
|
+
end
|
34
|
+
|
35
|
+
specify "with custom config" do
|
36
|
+
described_class.config.raw = true
|
37
|
+
described_class.config.mode = :cpu
|
38
|
+
|
39
|
+
expect(stack_prof).to receive(:start).with(
|
40
|
+
mode: :cpu,
|
41
|
+
raw: true
|
42
|
+
)
|
43
|
+
|
44
|
+
described_class.profile
|
45
|
+
end
|
46
|
+
|
47
|
+
specify "when block is given" do
|
48
|
+
expect(stack_prof).to receive(:run).with(
|
49
|
+
out: "tmp/stack-prof-report-wall-stub.dump",
|
50
|
+
mode: :wall,
|
51
|
+
raw: false
|
52
|
+
)
|
53
|
+
|
54
|
+
described_class.profile("stub") { 0 == 1 }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#dump" do
|
59
|
+
let(:stack_prof) { double("stack_prof") }
|
60
|
+
|
61
|
+
before do
|
62
|
+
stub_const("StackProf", stack_prof)
|
63
|
+
end
|
64
|
+
|
65
|
+
it "stops profiling and stores results" do
|
66
|
+
expect(stack_prof).to receive(:results).with(
|
67
|
+
"tmp/stack-prof-report-wall-stub.dump"
|
68
|
+
)
|
69
|
+
expect(stack_prof).to receive(:stop)
|
70
|
+
described_class.dump("stub")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe TestProf do
|
6
|
+
describe "#with_timestamps" do
|
7
|
+
context "when enabled" do
|
8
|
+
before { described_class.config.timestamps = false }
|
9
|
+
|
10
|
+
it { expect(described_class.with_timestamps("a/b/c.html")).to eq 'a/b/c.html' }
|
11
|
+
end
|
12
|
+
|
13
|
+
context "when enabled" do
|
14
|
+
before do
|
15
|
+
described_class.config.timestamps = true
|
16
|
+
expect(Time).to receive(:now).and_return(double("now", to_i: 123_454_321))
|
17
|
+
end
|
18
|
+
|
19
|
+
it { expect(described_class.with_timestamps("a/b/c.html")).to eq 'a/b/c-123454321.html' }
|
20
|
+
it { expect(described_class.with_timestamps("a/b/c")).to eq 'a/b/c-123454321' }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/test-prof.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'test_prof/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "test-prof"
|
8
|
+
spec.version = TestProf::VERSION
|
9
|
+
spec.authors = ["Vladimir Dementyev"]
|
10
|
+
spec.email = ["dementiev.vm@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = "Ruby applications tests profiling tools"
|
13
|
+
spec.description = %{
|
14
|
+
Ruby applications tests profiling tools.
|
15
|
+
|
16
|
+
Contains tools to anylyze factories usage, integrate with Ruby profilers,
|
17
|
+
profile your examples using ActiveSupport notifications (if any) and
|
18
|
+
statically analyze your code with custom Rubocop cops.
|
19
|
+
}
|
20
|
+
spec.homepage = "http://github.com/palkan/test-prof"
|
21
|
+
spec.license = "MIT"
|
22
|
+
|
23
|
+
spec.files = `git ls-files`.split($/)
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
29
|
+
spec.add_development_dependency "activerecord", "~> 5.0"
|
30
|
+
spec.add_development_dependency "factory_girl", "~> 4.8.0"
|
31
|
+
spec.add_development_dependency "rubocop", "~> 0.49"
|
32
|
+
spec.add_development_dependency "pry-byebug"
|
33
|
+
spec.add_development_dependency "sqlite3"
|
34
|
+
spec.add_development_dependency "sidekiq", "~> 4.0"
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test-prof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vladimir Dementyev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.5'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '5.9'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '5.9'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: activerecord
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,34 +146,25 @@ executables: []
|
|
160
146
|
extensions: []
|
161
147
|
extra_rdoc_files: []
|
162
148
|
files:
|
163
|
-
-
|
149
|
+
- ".gitignore"
|
150
|
+
- ".rspec"
|
151
|
+
- ".rubocop.yml"
|
152
|
+
- ".travis.yml"
|
153
|
+
- Gemfile
|
164
154
|
- LICENSE.txt
|
165
155
|
- README.md
|
166
|
-
-
|
167
|
-
-
|
168
|
-
-
|
169
|
-
- assets/src/d3-tip.min.js
|
170
|
-
- assets/src/d3.flameGraph.css
|
171
|
-
- assets/src/d3.flameGraph.js
|
172
|
-
- assets/src/d3.flameGraph.min.css
|
173
|
-
- assets/src/d3.flameGraph.min.js
|
174
|
-
- assets/src/d3.v4.min.js
|
156
|
+
- Rakefile
|
157
|
+
- bin/setup
|
158
|
+
- circle.yml
|
175
159
|
- guides/any_fixture.md
|
176
160
|
- guides/before_all.md
|
177
161
|
- guides/event_prof.md
|
178
|
-
- guides/factory_default.md
|
179
162
|
- guides/factory_doctor.md
|
180
|
-
- guides/factory_prof.md
|
181
|
-
- guides/rspec_stamp.md
|
182
|
-
- guides/rubocop.md
|
183
163
|
- guides/ruby_prof.md
|
184
164
|
- guides/stack_prof.md
|
185
|
-
- guides/tag_prof.md
|
186
|
-
- guides/tests_sampling.md
|
187
165
|
- lib/test-prof.rb
|
188
166
|
- lib/test_prof.rb
|
189
167
|
- lib/test_prof/any_fixture.rb
|
190
|
-
- lib/test_prof/cops/rspec/aggregate_failures.rb
|
191
168
|
- lib/test_prof/event_prof.rb
|
192
169
|
- lib/test_prof/event_prof/custom_events.rb
|
193
170
|
- lib/test_prof/event_prof/custom_events/factory_create.rb
|
@@ -197,33 +174,41 @@ files:
|
|
197
174
|
- lib/test_prof/event_prof/minitest.rb
|
198
175
|
- lib/test_prof/event_prof/rspec.rb
|
199
176
|
- lib/test_prof/ext/float_duration.rb
|
200
|
-
- lib/test_prof/factory_default.rb
|
201
|
-
- lib/test_prof/factory_default/factory_girl_patch.rb
|
202
177
|
- lib/test_prof/factory_doctor.rb
|
203
178
|
- lib/test_prof/factory_doctor/factory_girl_patch.rb
|
204
179
|
- lib/test_prof/factory_doctor/minitest.rb
|
205
180
|
- lib/test_prof/factory_doctor/rspec.rb
|
206
|
-
- lib/test_prof/factory_prof.rb
|
207
|
-
- lib/test_prof/factory_prof/factory_girl_patch.rb
|
208
|
-
- lib/test_prof/factory_prof/printers/flamegraph.rb
|
209
|
-
- lib/test_prof/factory_prof/printers/simple.rb
|
210
181
|
- lib/test_prof/logging.rb
|
211
|
-
- lib/test_prof/recipes/minitest/sample.rb
|
212
182
|
- lib/test_prof/recipes/rspec/any_fixture.rb
|
213
183
|
- lib/test_prof/recipes/rspec/before_all.rb
|
214
|
-
- lib/test_prof/recipes/rspec/factory_default.rb
|
215
|
-
- lib/test_prof/recipes/rspec/sample.rb
|
216
|
-
- lib/test_prof/rspec_stamp.rb
|
217
|
-
- lib/test_prof/rspec_stamp/parser.rb
|
218
|
-
- lib/test_prof/rspec_stamp/rspec.rb
|
219
|
-
- lib/test_prof/rubocop.rb
|
220
184
|
- lib/test_prof/ruby_prof.rb
|
221
185
|
- lib/test_prof/ruby_prof/rspec.rb
|
222
186
|
- lib/test_prof/stack_prof.rb
|
223
187
|
- lib/test_prof/stack_prof/rspec.rb
|
224
|
-
- lib/test_prof/tag_prof.rb
|
225
|
-
- lib/test_prof/tag_prof/rspec.rb
|
226
188
|
- lib/test_prof/version.rb
|
189
|
+
- spec/integrations/any_fixture_spec.rb
|
190
|
+
- spec/integrations/before_all_spec.rb
|
191
|
+
- spec/integrations/event_prof_spec.rb
|
192
|
+
- spec/integrations/factory_doctor_spec.rb
|
193
|
+
- spec/integrations/fixtures/rspec/any_fixture_fixture.rb
|
194
|
+
- spec/integrations/fixtures/rspec/before_all_fixture.rb
|
195
|
+
- spec/integrations/fixtures/rspec/event_prof_factory_create_fixture.rb
|
196
|
+
- spec/integrations/fixtures/rspec/event_prof_fixture.rb
|
197
|
+
- spec/integrations/fixtures/rspec/event_prof_sidekiq_fixture.rb
|
198
|
+
- spec/integrations/fixtures/rspec/factory_doctor_fixture.rb
|
199
|
+
- spec/spec_helper.rb
|
200
|
+
- spec/support/ar_models.rb
|
201
|
+
- spec/support/instrumenter_stub.rb
|
202
|
+
- spec/support/integration_helpers.rb
|
203
|
+
- spec/support/transactional_context.rb
|
204
|
+
- spec/test_prof/any_fixture_spec.rb
|
205
|
+
- spec/test_prof/event_prof_spec.rb
|
206
|
+
- spec/test_prof/ext/float_duration_spec.rb
|
207
|
+
- spec/test_prof/factory_doctor_spec.rb
|
208
|
+
- spec/test_prof/ruby_prof_spec.rb
|
209
|
+
- spec/test_prof/stack_prof_spec.rb
|
210
|
+
- spec/test_prof_spec.rb
|
211
|
+
- test-prof.gemspec
|
227
212
|
homepage: http://github.com/palkan/test-prof
|
228
213
|
licenses:
|
229
214
|
- MIT
|
@@ -244,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
229
|
version: 1.3.1
|
245
230
|
requirements: []
|
246
231
|
rubyforge_project:
|
247
|
-
rubygems_version: 2.6.
|
232
|
+
rubygems_version: 2.6.4
|
248
233
|
signing_key:
|
249
234
|
specification_version: 4
|
250
235
|
summary: Ruby applications tests profiling tools
|
data/CHANGELOG.md
DELETED
data/assets/flamegraph.demo.html
DELETED
@@ -1,173 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>TestProf: FactoryFlame</title>
|
5
|
-
<meta name="viewport" content="width=device-width">
|
6
|
-
<meta charset="UTF-8">
|
7
|
-
<link rel="stylesheet" type="text/css" href="src/d3.flameGraph.css">
|
8
|
-
<style>
|
9
|
-
html, body {
|
10
|
-
height: 100%;
|
11
|
-
width: 100%;
|
12
|
-
min-width: 300px;
|
13
|
-
}
|
14
|
-
|
15
|
-
body {
|
16
|
-
background: #f9f9f9;
|
17
|
-
color: #363636;
|
18
|
-
font: 18px/30px "Arial",sans-serif;
|
19
|
-
margin: 0;
|
20
|
-
padding: 0;
|
21
|
-
}
|
22
|
-
|
23
|
-
a {
|
24
|
-
text-decoration: none;
|
25
|
-
color: #ff5e5e
|
26
|
-
}
|
27
|
-
|
28
|
-
a:visited, a:active{
|
29
|
-
color: #ff5e5e;
|
30
|
-
}
|
31
|
-
|
32
|
-
a:hover{
|
33
|
-
opacity: 0.8;
|
34
|
-
}
|
35
|
-
|
36
|
-
h1 {
|
37
|
-
font-size: 30px;
|
38
|
-
line-height: 32px;
|
39
|
-
letter-spacing: 2px;
|
40
|
-
font-weight: bold;
|
41
|
-
padding: 30px 0 30px 0;
|
42
|
-
margin: 0;
|
43
|
-
}
|
44
|
-
|
45
|
-
.main {
|
46
|
-
height: 100%;
|
47
|
-
width: 100%;
|
48
|
-
margin: 0;
|
49
|
-
padding: 0;
|
50
|
-
}
|
51
|
-
|
52
|
-
header {
|
53
|
-
position: relative;
|
54
|
-
text-align: center;
|
55
|
-
background: #fff;
|
56
|
-
overflow: hidden;
|
57
|
-
display: flex;
|
58
|
-
align-items: center;
|
59
|
-
flex-direction: column;
|
60
|
-
}
|
61
|
-
|
62
|
-
.chart {
|
63
|
-
display: flex;
|
64
|
-
align-items: center;
|
65
|
-
position: relative;
|
66
|
-
box-sizing: border-box;
|
67
|
-
flex-direction: column;
|
68
|
-
}
|
69
|
-
|
70
|
-
.humanoids__link {
|
71
|
-
width: 130px;
|
72
|
-
}
|
73
|
-
|
74
|
-
.humanoids{
|
75
|
-
position: absolute;
|
76
|
-
bottom: -23px;
|
77
|
-
width: 150px;
|
78
|
-
height: 60px;
|
79
|
-
margin: 0 auto 0 -10px;
|
80
|
-
font-size: 0;
|
81
|
-
transform: scale(0.6);
|
82
|
-
}
|
83
|
-
.humanoids circle{
|
84
|
-
transform: scaleY(1);
|
85
|
-
transform-origin: 50%;
|
86
|
-
animation-duration: 8s;
|
87
|
-
animation-name: humanoids-blink;
|
88
|
-
animation-iteration-count: infinite;
|
89
|
-
}
|
90
|
-
.humanoids svg{
|
91
|
-
height: 60px;
|
92
|
-
}
|
93
|
-
.humanoids__human, .humanoids__martian{
|
94
|
-
position: absolute;
|
95
|
-
width: 80px;
|
96
|
-
height: 90px;
|
97
|
-
transition: transform 300ms cubic-bezier(0.68, -0.55, 0.265, 1.55);
|
98
|
-
transform: translateY(0);
|
99
|
-
}
|
100
|
-
.humanoids__human:hover, .humanoids__martian:hover{
|
101
|
-
transform: translateY(-12px);
|
102
|
-
}
|
103
|
-
.humanoids__martian{
|
104
|
-
left: 0;
|
105
|
-
}
|
106
|
-
.humanoids__human{
|
107
|
-
right: 0;
|
108
|
-
}
|
109
|
-
.humanoids__human circle{
|
110
|
-
animation-delay: 0.5s;
|
111
|
-
}
|
112
|
-
|
113
|
-
[name="root"] .label {
|
114
|
-
text-align: center;
|
115
|
-
}
|
116
|
-
</style>
|
117
|
-
</head>
|
118
|
-
<body>
|
119
|
-
<div class="main">
|
120
|
-
<header>
|
121
|
-
<h1>FactoryFlame Report</h1>
|
122
|
-
<a class="humanoids__link" href="https://evilmartians.com">
|
123
|
-
<div class="humanoids">
|
124
|
-
<div class="humanoids__martian"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 92"><path fill="#f64242" d="M26 88L8 78l18-10"/><path fill="#f64242" d="M94 92v-6H44c-5.5 0-10-4.5-10-10s4.5-10 10-10h50V32c0-14-7.9-22-22-22H48c-14.1 0-22 8-22 22v60h68z"/><circle fill="#FFF" cx="48" cy="50" r="8"/><circle fill="#FFF" cx="72" cy="50" r="8"/><circle fill="#BF6C35" cx="48" cy="50" r="4"/><circle fill="#BF6C35" cx="72" cy="50" r="4"/><g fill="#663F4C"><path d="M48 60c-5.5 0-10-4.5-10-10s4.5-10 10-10 10 4.5 10 10-4.5 10-10 10zm0-16c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6-2.7-6-6-6zM82 50c0 5.5-4.5 10-10 10s-10-4.5-10-10 4.5-10 10-10 10 4.5 10 10zm-16 0c0 3.3 2.7 6 6 6s6-2.7 6-6-2.7-6-6-6-6 2.7-6 6z"/><path d="M102 8c-3.8 0-6-2.2-6-6 0-1.1-.9-2-2-2s-2 .9-2 2c0 2.2.5 4.1 1.5 5.7L88.2 13c-4-3.3-9.5-5-16.2-5H48c-6.7 0-12.2 1.7-16.2 4.9l-5.3-5.3C27.5 6.1 28 4.2 28 2c0-1.1-.9-2-2-2s-2 .9-2 2c0 3.8-2.2 6-6 6-1.1 0-2 .9-2 2s.9 2 2 2c2.2 0 4.1-.5 5.7-1.5l5.3 5.3c-3.2 4-4.9 9.5-4.9 16.2v34.8L3.9 78 24 89v3h4V32c0-12.9 7.1-20 20-20h24c12.9 0 20 7.1 20 20v32H44c-6.6 0-12 5.4-12 12s5.4 12 12 12h48v4h4v-8h-2l-4-8-4 8h-4l-4-8-4 8h-4l-4-8-4 8h-4l-4-8-4 8h-4l-4-8-3.1 6.2C37.1 80.7 36 78.5 36 76c0-4.4 3.6-8 8-8l4 8 4-8h4l4 8 4-8h4l4 8 4-8h4l4 8 4-8h8V32c0-6.7-1.7-12.2-4.9-16.2l5.3-5.3c1.6 1 3.5 1.5 5.7 1.5 1.1 0 2-.9 2-2s-1-2-2.1-2zM24 84.4L12.1 78 24 71.4v13z"/></g></svg></div>
|
125
|
-
<div class="humanoids__human"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 108 92"><path fill="#FFFFFF" d="M14 62v30h68v-6H32c-5.5 0-10-4.5-10-10s4.5-10 10-10h50v-4c4 0 8-3.6 8-8s-4-8-8-8V32c0-14-7.9-22-22-22H36c-14.1 0-22 8-22 22v14c-4 0-8 3.6-8 8s4 8 8 8z"/><circle fill="#FFF" cx="36" cy="50" r="8"/><circle fill="#FFF" cx="60" cy="50" r="8"/><circle fill="#f64242" cx="36" cy="50" r="4"/><circle fill="#f64242" cx="60" cy="50" r="4"/><path fill="#f64242" d="M60 10H36c-14.1 0-22 8-22 22v2l4-4 6 6 6-6 6 6 6-6 6 6 6-6 6 6 6-6 6 6 6-6 4 4v-2c0-14-7.9-22-22-22z"/><g fill="#663F4C"><path d="M36 60c-5.5 0-10-4.5-10-10s4.5-10 10-10 10 4.5 10 10-4.5 10-10 10zm0-16c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6-2.7-6-6-6zM60 60c-5.5 0-10-4.5-10-10s4.5-10 10-10 10 4.5 10 10-4.5 10-10 10zm0-16c-3.3 0-6 2.7-6 6s2.7 6 6 6 6-2.7 6-6-2.7-6-6-6z"/><path d="M12 63.8V92h4V32c0-12.9 7.1-20 20-20h24c12.9 0 20 7.1 20 20v32H32c-6.6 0-12 5.4-12 12s5.4 12 12 12h48v4h4v-8H74v-1c0-1.7-1.3-3-3-3s-3 1.3-3 3v1h-6v-1c0-1.7-1.3-3-3-3s-3 1.3-3 3v1h-6v-1c0-1.7-1.3-3-3-3s-3 1.3-3 3v1h-6v-1c0-1.7-1.3-3-3-3s-3 1.3-3 3v1c-4 0-8-3.6-8-8s3.6-8 8-8h6v1c0 1.7 1.3 3 3 3s3-1.3 3-3v-1h6v1c0 1.7 1.3 3 3 3s3-1.3 3-3v-1h6v1c0 1.7 1.3 3 3 3s3-1.3 3-3v-1h6v1c0 1.7 1.3 3 3 3s3-1.3 3-3v-1h4v-4.2c5-.9 8-5 8-9.8s-3-8.9-8-9.8V32c0-15.3-8.7-24-24-24H36c-15.3 0-24 8.7-24 24v12.2c-5 .9-8 5-8 9.8s3 8.9 8 9.8zm72-15.5c2 .8 4 3 4 5.7s-2 4.8-4 5.7V48.3zm-72 0v11.3c-2-.8-4-3-4-5.7s2-4.7 4-5.6z"/></g></svg></div>
|
126
|
-
</div>
|
127
|
-
</a>
|
128
|
-
</header>
|
129
|
-
<div class="chart">
|
130
|
-
<div id="chart">
|
131
|
-
</div>
|
132
|
-
<hr>
|
133
|
-
<div id="details">
|
134
|
-
</div>
|
135
|
-
</div>
|
136
|
-
</div>
|
137
|
-
|
138
|
-
<script type="text/javascript" src="src/d3.v4.min.js"></script>
|
139
|
-
<script type="text/javascript" src="src/d3-tip.js"></script>
|
140
|
-
<script type="text/javascript" src="src/d3.flameGraph.js"></script>
|
141
|
-
|
142
|
-
<script type="text/javascript">
|
143
|
-
var flameGraph = d3.flameGraph()
|
144
|
-
.height(360)
|
145
|
-
.cellHeight(18)
|
146
|
-
.transitionDuration(750)
|
147
|
-
.transitionEase(d3.easeCubic)
|
148
|
-
.title("");
|
149
|
-
|
150
|
-
// Example on how to use custom tooltips using d3-tip.
|
151
|
-
var tip = d3.tip()
|
152
|
-
.direction("s")
|
153
|
-
.offset([8, 0])
|
154
|
-
.attr('class', 'd3-flame-graph-tip')
|
155
|
-
.html(function(d) { return "name: " + d.data.name + ", total: " + d.data.value; });
|
156
|
-
|
157
|
-
flameGraph.tooltip(tip);
|
158
|
-
|
159
|
-
report_data = JSON.parse('{"total":27,"roots":[{"name":"user","value":21,"children":[{"name":"account","value":20}]},{"name":"post","value":1,"children":[{"name":"account","value":1,"children":[{"name":"user","value":1,"children":[{"name":"account","value":1}]}]}]},{"name":"comment","value":4,"children":[{"name":"post","value":1},{"name":"user","value":3,"children":[{"name":"account","value":3,"children":[{"name":"post","value":2,"children":[{"name":"account","value":2,"children":[{"name":"user","value":2,"children":[{"name":"account","value":2,"children":[{"name":"subscription","value":2,"children":[{"name":"order","value":2,"children":[{"name":"account","value":2,"children":[{"name":"user","value":2,"children":[{"name":"profile","value":2,"children":[{"name":"post","value":1,"children":[{"name":"account","value":1,"children":[{"name":"user","value":1,"children":[{"name":"account","value":1,"children":[{"name":"subscription","value":1}]}]}]}]}]}]}]}]}]}]}]}]}]},{"name":"user","value":1,"children":[{"name":"account","value":1,"children":[{"name":"subscription","value":1,"children":[{"name":"order","value":1,"children":[{"name":"account","value":1,"children":[{"name":"user","value":1,"children":[{"name":"profile","value":1}]}]}]}]}]}]}]}]}]},{"name":"account","value":1}]}');
|
160
|
-
|
161
|
-
data = {
|
162
|
-
name: "root",
|
163
|
-
value: report_data.total,
|
164
|
-
color: "#9e9e9e",
|
165
|
-
children: report_data.roots
|
166
|
-
};
|
167
|
-
|
168
|
-
d3.select("#chart")
|
169
|
-
.datum(data)
|
170
|
-
.call(flameGraph);
|
171
|
-
</script>
|
172
|
-
</body>
|
173
|
-
</html>
|