test-prof 0.1.0.beta1 → 0.1.0.pre5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.rubocop.yml +69 -0
  5. data/.travis.yml +5 -0
  6. data/Gemfile +4 -0
  7. data/README.md +2 -6
  8. data/Rakefile +8 -0
  9. data/bin/setup +8 -0
  10. data/circle.yml +11 -0
  11. data/guides/any_fixture.md +1 -1
  12. data/guides/stack_prof.md +1 -1
  13. data/lib/test_prof/factory_doctor.rb +9 -11
  14. data/lib/test_prof/ruby_prof.rb +5 -2
  15. data/lib/test_prof/stack_prof.rb +5 -2
  16. data/lib/test_prof/version.rb +1 -1
  17. data/lib/test_prof.rb +1 -19
  18. data/spec/integrations/any_fixture_spec.rb +11 -0
  19. data/spec/integrations/before_all_spec.rb +11 -0
  20. data/spec/integrations/event_prof_spec.rb +100 -0
  21. data/spec/integrations/factory_doctor_spec.rb +20 -0
  22. data/spec/integrations/fixtures/rspec/any_fixture_fixture.rb +37 -0
  23. data/spec/integrations/fixtures/rspec/before_all_fixture.rb +32 -0
  24. data/spec/integrations/fixtures/rspec/event_prof_factory_create_fixture.rb +23 -0
  25. data/spec/integrations/fixtures/rspec/event_prof_fixture.rb +51 -0
  26. data/spec/integrations/fixtures/rspec/event_prof_sidekiq_fixture.rb +53 -0
  27. data/spec/integrations/fixtures/rspec/factory_doctor_fixture.rb +33 -0
  28. data/spec/integrations/fixtures/rspec/rspec_stamp_fixture_tmpl.rb +33 -0
  29. data/spec/integrations/rspec_stamp_spec.rb +53 -0
  30. data/spec/spec_helper.rb +38 -0
  31. data/spec/support/ar_models.rb +43 -0
  32. data/spec/support/instrumenter_stub.rb +19 -0
  33. data/spec/support/integration_helpers.rb +13 -0
  34. data/spec/support/transactional_context.rb +11 -0
  35. data/spec/test_prof/any_fixture_spec.rb +66 -0
  36. data/spec/test_prof/event_prof_spec.rb +138 -0
  37. data/spec/test_prof/ext/float_duration_spec.rb +12 -0
  38. data/spec/test_prof/factory_doctor_spec.rb +84 -0
  39. data/spec/test_prof/rspec_stamp/parser_spec.rb +58 -0
  40. data/spec/test_prof/rspec_stamp_spec.rb +281 -0
  41. data/spec/test_prof/ruby_prof_spec.rb +109 -0
  42. data/spec/test_prof/stack_prof_spec.rb +73 -0
  43. data/spec/test_prof_spec.rb +23 -0
  44. data/test-prof.gemspec +35 -0
  45. metadata +38 -21
  46. data/CHANGELOG.md +0 -7
  47. data/assets/flamegraph.demo.html +0 -173
  48. data/assets/flamegraph.template.html +0 -196
  49. data/assets/src/d3-tip.js +0 -352
  50. data/assets/src/d3-tip.min.js +0 -1
  51. data/assets/src/d3.flameGraph.css +0 -92
  52. data/assets/src/d3.flameGraph.js +0 -459
  53. data/assets/src/d3.flameGraph.min.css +0 -1
  54. data/assets/src/d3.flameGraph.min.js +0 -1
  55. data/assets/src/d3.v4.min.js +0 -8
  56. data/guides/factory_prof.md +0 -85
  57. data/guides/rubocop.md +0 -48
  58. data/lib/test_prof/cops/rspec/aggregate_failures.rb +0 -140
  59. data/lib/test_prof/factory_prof/factory_girl_patch.rb +0 -12
  60. data/lib/test_prof/factory_prof/printers/flamegraph.rb +0 -71
  61. data/lib/test_prof/factory_prof/printers/simple.rb +0 -28
  62. data/lib/test_prof/factory_prof.rb +0 -140
  63. data/lib/test_prof/rubocop.rb +0 -3
data/assets/src/d3-tip.js DELETED
@@ -1,352 +0,0 @@
1
- /**
2
- * d3.tip
3
- * Copyright (c) 2013-2017 Justin Palmer
4
- *
5
- * Tooltips for d3.js SVG visualizations
6
- */
7
- // eslint-disable-next-line no-extra-semi
8
- ;(function(root, factory) {
9
- if (typeof define === 'function' && define.amd) {
10
- // AMD. Register as an anonymous module with d3 as a dependency.
11
- define([
12
- 'd3-collection',
13
- 'd3-selection'
14
- ], factory)
15
- } else if (typeof module === 'object' && module.exports) {
16
- /* eslint-disable global-require */
17
- // CommonJS
18
- var d3Collection = require('d3-collection'),
19
- d3Selection = require('d3-selection')
20
- module.exports = factory(d3Collection, d3Selection)
21
- /* eslint-enable global-require */
22
- } else {
23
- // Browser global.
24
- var d3 = root.d3
25
- // eslint-disable-next-line no-param-reassign
26
- root.d3.tip = factory(d3, d3)
27
- }
28
- }(this, function(d3Collection, d3Selection) {
29
- // Public - contructs a new tooltip
30
- //
31
- // Returns a tip
32
- return function() {
33
- var direction = d3TipDirection,
34
- offset = d3TipOffset,
35
- html = d3TipHTML,
36
- rootElement = document.body,
37
- node = initNode(),
38
- svg = null,
39
- point = null,
40
- target = null
41
-
42
- function tip(vis) {
43
- svg = getSVGNode(vis)
44
- if (!svg) return
45
- point = svg.createSVGPoint()
46
- rootElement.appendChild(node)
47
- }
48
-
49
- // Public - show the tooltip on the screen
50
- //
51
- // Returns a tip
52
- tip.show = function() {
53
- var args = Array.prototype.slice.call(arguments)
54
- if (args[args.length - 1] instanceof SVGElement) target = args.pop()
55
-
56
- var content = html.apply(this, args),
57
- poffset = offset.apply(this, args),
58
- dir = direction.apply(this, args),
59
- nodel = getNodeEl(),
60
- i = directions.length,
61
- coords,
62
- scrollTop = document.documentElement.scrollTop ||
63
- rootElement.scrollTop,
64
- scrollLeft = document.documentElement.scrollLeft ||
65
- rootElement.scrollLeft
66
-
67
- nodel.html(content)
68
- .style('opacity', 1).style('pointer-events', 'all')
69
-
70
- while (i--) nodel.classed(directions[i], false)
71
- coords = directionCallbacks.get(dir).apply(this)
72
- nodel.classed(dir, true)
73
- .style('top', (coords.top + poffset[0]) + scrollTop + 'px')
74
- .style('left', (coords.left + poffset[1]) + scrollLeft + 'px')
75
-
76
- return tip
77
- }
78
-
79
- // Public - hide the tooltip
80
- //
81
- // Returns a tip
82
- tip.hide = function() {
83
- var nodel = getNodeEl()
84
- nodel.style('opacity', 0).style('pointer-events', 'none')
85
- return tip
86
- }
87
-
88
- // Public: Proxy attr calls to the d3 tip container.
89
- // Sets or gets attribute value.
90
- //
91
- // n - name of the attribute
92
- // v - value of the attribute
93
- //
94
- // Returns tip or attribute value
95
- // eslint-disable-next-line no-unused-vars
96
- tip.attr = function(n, v) {
97
- if (arguments.length < 2 && typeof n === 'string') {
98
- return getNodeEl().attr(n)
99
- }
100
-
101
- var args = Array.prototype.slice.call(arguments)
102
- d3Selection.selection.prototype.attr.apply(getNodeEl(), args)
103
- return tip
104
- }
105
-
106
- // Public: Proxy style calls to the d3 tip container.
107
- // Sets or gets a style value.
108
- //
109
- // n - name of the property
110
- // v - value of the property
111
- //
112
- // Returns tip or style property value
113
- // eslint-disable-next-line no-unused-vars
114
- tip.style = function(n, v) {
115
- if (arguments.length < 2 && typeof n === 'string') {
116
- return getNodeEl().style(n)
117
- }
118
-
119
- var args = Array.prototype.slice.call(arguments)
120
- d3Selection.selection.prototype.style.apply(getNodeEl(), args)
121
- return tip
122
- }
123
-
124
- // Public: Set or get the direction of the tooltip
125
- //
126
- // v - One of n(north), s(south), e(east), or w(west), nw(northwest),
127
- // sw(southwest), ne(northeast) or se(southeast)
128
- //
129
- // Returns tip or direction
130
- tip.direction = function(v) {
131
- if (!arguments.length) return direction
132
- direction = v == null ? v : functor(v)
133
-
134
- return tip
135
- }
136
-
137
- // Public: Sets or gets the offset of the tip
138
- //
139
- // v - Array of [x, y] offset
140
- //
141
- // Returns offset or
142
- tip.offset = function(v) {
143
- if (!arguments.length) return offset
144
- offset = v == null ? v : functor(v)
145
-
146
- return tip
147
- }
148
-
149
- // Public: sets or gets the html value of the tooltip
150
- //
151
- // v - String value of the tip
152
- //
153
- // Returns html value or tip
154
- tip.html = function(v) {
155
- if (!arguments.length) return html
156
- html = v == null ? v : functor(v)
157
-
158
- return tip
159
- }
160
-
161
- // Public: sets or gets the root element anchor of the tooltip
162
- //
163
- // v - root element of the tooltip
164
- //
165
- // Returns root node of tip
166
- tip.rootElement = function(v) {
167
- if (!arguments.length) return rootElement
168
- rootElement = v == null ? v : functor(v)
169
-
170
- return tip
171
- }
172
-
173
- // Public: destroys the tooltip and removes it from the DOM
174
- //
175
- // Returns a tip
176
- tip.destroy = function() {
177
- if (node) {
178
- getNodeEl().remove()
179
- node = null
180
- }
181
- return tip
182
- }
183
-
184
- function d3TipDirection() { return 'n' }
185
- function d3TipOffset() { return [0, 0] }
186
- function d3TipHTML() { return ' ' }
187
-
188
- var directionCallbacks = d3Collection.map({
189
- n: directionNorth,
190
- s: directionSouth,
191
- e: directionEast,
192
- w: directionWest,
193
- nw: directionNorthWest,
194
- ne: directionNorthEast,
195
- sw: directionSouthWest,
196
- se: directionSouthEast
197
- }),
198
- directions = directionCallbacks.keys()
199
-
200
- function directionNorth() {
201
- var bbox = getScreenBBox()
202
- return {
203
- top: bbox.n.y - node.offsetHeight,
204
- left: bbox.n.x - node.offsetWidth / 2
205
- }
206
- }
207
-
208
- function directionSouth() {
209
- var bbox = getScreenBBox()
210
- return {
211
- top: bbox.s.y,
212
- left: bbox.s.x - node.offsetWidth / 2
213
- }
214
- }
215
-
216
- function directionEast() {
217
- var bbox = getScreenBBox()
218
- return {
219
- top: bbox.e.y - node.offsetHeight / 2,
220
- left: bbox.e.x
221
- }
222
- }
223
-
224
- function directionWest() {
225
- var bbox = getScreenBBox()
226
- return {
227
- top: bbox.w.y - node.offsetHeight / 2,
228
- left: bbox.w.x - node.offsetWidth
229
- }
230
- }
231
-
232
- function directionNorthWest() {
233
- var bbox = getScreenBBox()
234
- return {
235
- top: bbox.nw.y - node.offsetHeight,
236
- left: bbox.nw.x - node.offsetWidth
237
- }
238
- }
239
-
240
- function directionNorthEast() {
241
- var bbox = getScreenBBox()
242
- return {
243
- top: bbox.ne.y - node.offsetHeight,
244
- left: bbox.ne.x
245
- }
246
- }
247
-
248
- function directionSouthWest() {
249
- var bbox = getScreenBBox()
250
- return {
251
- top: bbox.sw.y,
252
- left: bbox.sw.x - node.offsetWidth
253
- }
254
- }
255
-
256
- function directionSouthEast() {
257
- var bbox = getScreenBBox()
258
- return {
259
- top: bbox.se.y,
260
- left: bbox.se.x
261
- }
262
- }
263
-
264
- function initNode() {
265
- var div = d3Selection.select(document.createElement('div'))
266
- div
267
- .style('position', 'absolute')
268
- .style('top', 0)
269
- .style('opacity', 0)
270
- .style('pointer-events', 'none')
271
- .style('box-sizing', 'border-box')
272
-
273
- return div.node()
274
- }
275
-
276
- function getSVGNode(element) {
277
- var svgNode = element.node()
278
- if (!svgNode) return null
279
- if (svgNode.tagName.toLowerCase() === 'svg') return svgNode
280
- return svgNode.ownerSVGElement
281
- }
282
-
283
- function getNodeEl() {
284
- if (node == null) {
285
- node = initNode()
286
- // re-add node to DOM
287
- rootElement.appendChild(node)
288
- }
289
- return d3Selection.select(node)
290
- }
291
-
292
- // Private - gets the screen coordinates of a shape
293
- //
294
- // Given a shape on the screen, will return an SVGPoint for the directions
295
- // n(north), s(south), e(east), w(west), ne(northeast), se(southeast),
296
- // nw(northwest), sw(southwest).
297
- //
298
- // +-+-+
299
- // | |
300
- // + +
301
- // | |
302
- // +-+-+
303
- //
304
- // Returns an Object {n, s, e, w, nw, sw, ne, se}
305
- function getScreenBBox() {
306
- var targetel = target || d3Selection.event.target
307
-
308
- while (targetel.getScreenCTM == null && targetel.parentNode == null) {
309
- targetel = targetel.parentNode
310
- }
311
-
312
- var bbox = {},
313
- matrix = targetel.getScreenCTM(),
314
- tbbox = targetel.getBBox(),
315
- width = tbbox.width,
316
- height = tbbox.height,
317
- x = tbbox.x,
318
- y = tbbox.y
319
-
320
- point.x = x
321
- point.y = y
322
- bbox.nw = point.matrixTransform(matrix)
323
- point.x += width
324
- bbox.ne = point.matrixTransform(matrix)
325
- point.y += height
326
- bbox.se = point.matrixTransform(matrix)
327
- point.x -= width
328
- bbox.sw = point.matrixTransform(matrix)
329
- point.y -= height / 2
330
- bbox.w = point.matrixTransform(matrix)
331
- point.x += width
332
- bbox.e = point.matrixTransform(matrix)
333
- point.x -= width / 2
334
- point.y -= height / 2
335
- bbox.n = point.matrixTransform(matrix)
336
- point.y += height
337
- bbox.s = point.matrixTransform(matrix)
338
-
339
- return bbox
340
- }
341
-
342
- // Private - replace D3JS 3.X d3.functor() function
343
- function functor(v) {
344
- return typeof v === 'function' ? v : function() {
345
- return v
346
- }
347
- }
348
-
349
- return tip
350
- }
351
- // eslint-disable-next-line semi
352
- }));
@@ -1 +0,0 @@
1
- !function(t,e){if("function"==typeof define&&define.amd)define(["d3-collection","d3-selection"],e);else if("object"==typeof module&&module.exports){var n=require("d3-collection"),r=require("d3-selection");module.exports=e(n,r)}else{var o=t.d3;t.d3.tip=e(o,o)}}(this,function(t,e){return function(){function n(t){(C=m(t))&&(H=C.createSVGPoint(),b.appendChild(E))}function r(){return"n"}function o(){return[0,0]}function l(){return" "}function i(){var t=x();return{top:t.n.y-E.offsetHeight,left:t.n.x-E.offsetWidth/2}}function f(){var t=x();return{top:t.s.y,left:t.s.x-E.offsetWidth/2}}function u(){var t=x();return{top:t.e.y-E.offsetHeight/2,left:t.e.x}}function s(){var t=x();return{top:t.w.y-E.offsetHeight/2,left:t.w.x-E.offsetWidth}}function a(){var t=x();return{top:t.nw.y-E.offsetHeight,left:t.nw.x-E.offsetWidth}}function c(){var t=x();return{top:t.ne.y-E.offsetHeight,left:t.ne.x}}function p(){var t=x();return{top:t.sw.y,left:t.sw.x-E.offsetWidth}}function y(){var t=x();return{top:t.se.y,left:t.se.x}}function d(){var t=e.select(document.createElement("div"));return t.style("position","absolute").style("top",0).style("opacity",0).style("pointer-events","none").style("box-sizing","border-box"),t.node()}function m(t){var e=t.node();return e?"svg"===e.tagName.toLowerCase()?e:e.ownerSVGElement:null}function h(){return null==E&&(E=d(),b.appendChild(E)),e.select(E)}function x(){for(var t=S||e.event.target;null==t.getScreenCTM&&null==t.parentNode;)t=t.parentNode;var n={},r=t.getScreenCTM(),o=t.getBBox(),l=o.width,i=o.height,f=o.x,u=o.y;return H.x=f,H.y=u,n.nw=H.matrixTransform(r),H.x+=l,n.ne=H.matrixTransform(r),H.y+=i,n.se=H.matrixTransform(r),H.x-=l,n.sw=H.matrixTransform(r),H.y-=i/2,n.w=H.matrixTransform(r),H.x+=l,n.e=H.matrixTransform(r),H.x-=l/2,H.y-=i/2,n.n=H.matrixTransform(r),H.y+=i,n.s=H.matrixTransform(r),n}function v(t){return"function"==typeof t?t:function(){return t}}var g=r,w=o,T=l,b=document.body,E=d(),C=null,H=null,S=null;n.show=function(){var t=Array.prototype.slice.call(arguments);t[t.length-1]instanceof SVGElement&&(S=t.pop());var e,r=T.apply(this,t),o=w.apply(this,t),l=g.apply(this,t),i=h(),f=A.length,u=document.documentElement.scrollTop||b.scrollTop,s=document.documentElement.scrollLeft||b.scrollLeft;for(i.html(r).style("opacity",1).style("pointer-events","all");f--;)i.classed(A[f],!1);return e=W.get(l).apply(this),i.classed(l,!0).style("top",e.top+o[0]+u+"px").style("left",e.left+o[1]+s+"px"),n},n.hide=function(){return h().style("opacity",0).style("pointer-events","none"),n},n.attr=function(t,r){if(arguments.length<2&&"string"==typeof t)return h().attr(t);var o=Array.prototype.slice.call(arguments);return e.selection.prototype.attr.apply(h(),o),n},n.style=function(t,r){if(arguments.length<2&&"string"==typeof t)return h().style(t);var o=Array.prototype.slice.call(arguments);return e.selection.prototype.style.apply(h(),o),n},n.direction=function(t){return arguments.length?(g=null==t?t:v(t),n):g},n.offset=function(t){return arguments.length?(w=null==t?t:v(t),n):w},n.html=function(t){return arguments.length?(T=null==t?t:v(t),n):T},n.rootElement=function(t){return arguments.length?(b=null==t?t:v(t),n):b},n.destroy=function(){return E&&(h().remove(),E=null),n};var W=t.map({n:i,s:f,e:u,w:s,nw:a,ne:c,sw:p,se:y}),A=W.keys();return n}});
@@ -1,92 +0,0 @@
1
- .d3-flame-graph rect {
2
- stroke: #EEEEEE;
3
- fill-opacity: .8;
4
- }
5
-
6
- .d3-flame-graph rect:hover {
7
- stroke: #474747;
8
- stroke-width: 0.5;
9
- cursor: pointer;
10
- }
11
-
12
- .d3-flame-graph .label {
13
- pointer-events: none;
14
- white-space: nowrap;
15
- text-overflow: ellipsis;
16
- overflow: hidden;
17
- font-size: 12px;
18
- font-family: Verdana;
19
- margin-left: 4px;
20
- margin-right: 4px;
21
- line-height: 1.5;
22
- padding: 0 0 0;
23
- font-weight: 400;
24
- color: black;
25
- text-align: left;
26
- }
27
-
28
- .d3-flame-graph .fade {
29
- opacity: 0.6 !important;
30
- }
31
-
32
- .d3-flame-graph .title {
33
- font-size: 20px;
34
- font-family: Verdana;
35
- }
36
-
37
- .d3-flame-graph-tip {
38
- line-height: 1;
39
- font-family: Verdana;
40
- font-size: 12px;
41
- padding: 12px;
42
- background: rgba(0, 0, 0, 0.8);
43
- color: #fff;
44
- border-radius: 2px;
45
- pointer-events: none;
46
- }
47
-
48
- /* Creates a small triangle extender for the tooltip */
49
- .d3-flame-graph-tip:after {
50
- box-sizing: border-box;
51
- display: inline;
52
- font-size: 10px;
53
- width: 100%;
54
- line-height: 1;
55
- color: rgba(0, 0, 0, 0.8);
56
- position: absolute;
57
- pointer-events: none;
58
- }
59
-
60
- /* Northward tooltips */
61
- .d3-flame-graph-tip.n:after {
62
- content: "\25BC";
63
- margin: -1px 0 0 0;
64
- top: 100%;
65
- left: 0;
66
- text-align: center;
67
- }
68
-
69
- /* Eastward tooltips */
70
- .d3-flame-graph-tip.e:after {
71
- content: "\25C0";
72
- margin: -4px 0 0 0;
73
- top: 50%;
74
- left: -8px;
75
- }
76
-
77
- /* Southward tooltips */
78
- .d3-flame-graph-tip.s:after {
79
- content: "\25B2";
80
- margin: 0 0 1px 0;
81
- top: -8px;
82
- left: 0;
83
- text-align: center;
84
- }
85
-
86
- /* Westward tooltips */
87
- .d3-flame-graph-tip.w:after {
88
- content: "\25B6";
89
- margin: -4px 0 0 -1px;
90
- top: 50%;
91
- left: 100%;
92
- }