flamegraph 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d6f147215ccb958640e914e56d3bd1ec6130228
4
- data.tar.gz: 4b5ba1debf723c7337b7d124d5d6dad981aaa9b6
3
+ metadata.gz: 5807961a031d5616c761cf1abd8cb40d0fcdf96d
4
+ data.tar.gz: 37504cd3a7eb373b5c032e16a42a18d034f9bc37
5
5
  SHA512:
6
- metadata.gz: 0003bcb764added6799e674c4f03682c1bd2ed578fd34c3fabd8384dd62133e2b5e8f713289a7d1809d4d57871fd463d444aaef352ee67b9f1f9dc6e627a94bb
7
- data.tar.gz: 1219aa97e31f1c2e0243a14846cced5338499bd71321a4d624cc2548a9102e0fa3e9747d7ddbc3f4c66865baa4e68fe7e37b9f449d3acbb92ed0e8f4a5da3631
6
+ metadata.gz: 513d03cd56555fb3a7973dca00ad3b7da31fb1eb63fccaac257b4d4e644f6542b3cb327e24182f69b1f271936102d8cb3c48487ed18581ff7d9602bc224f9468
7
+ data.tar.gz: 8557a47733c0af654c35a7c099580f1d4643dd928d2d2ea8919276928bf07a070982fd1ce289f3acc04057dbe21dc719cb2d31ab2d5377c3f85f7e1621fa0e9e
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
1
  3-Sep-2013
2
2
 
3
3
  - Added fast_stack for more accurate graphing
4
+
5
+ 12-Sep-2013
6
+
7
+ - 0.0.3
8
+ - Corrected analysis of gem file name, ensured gems are ordered by usage
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Flamegraph
2
2
 
3
- Flamegraph support for arbitrary Ruby apps
3
+ Flamegraph support for arbitrary Ruby apps.
4
+
5
+ Note, flamegraph support is built in to rack-mini-profiler, just require this gem and you should be good to go.
6
+ Type ?pp=flamegraph to create one for the current page.
4
7
 
5
8
  ## Installation
6
9
 
@@ -3,7 +3,10 @@
3
3
  <head>
4
4
  <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
5
5
  <script src="//cdnjs.cloudflare.com/ajax/libs/d3/3.0.8/d3.min.js"></script>
6
+ <script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/1.3.1/lodash.min.js"></script>
7
+
6
8
  <meta charset=utf-8 />
9
+
7
10
  <title>Flame Graph of Page</title>
8
11
  <style>
9
12
  .info {height: 40px;}
@@ -72,7 +75,7 @@ var guessGem = function(frame)
72
75
  }
73
76
 
74
77
  split = split[Math.max(split.length-2,0)].split('/');
75
- return split[split.length-1];
78
+ return split[split.length-1].split(':')[0];
76
79
  }
77
80
  else
78
81
  {
@@ -226,7 +229,7 @@ $.each(data, function(){
226
229
  var stat = gemStats[gem];
227
230
 
228
231
  if(!stat) {
229
- gemStats[gem] = stat = {samples: [], frames: []};
232
+ gemStats[gem] = stat = {name: gem, samples: [], frames: []};
230
233
  }
231
234
 
232
235
  stat.frames.push(this.frame);
@@ -254,14 +257,23 @@ topFrame.exclusiveCount += 1;
254
257
  lastFrame.topFrame = topFrame;
255
258
 
256
259
  var totalGems = 0;
257
- $.each(gemStats, function(){totalGems++;});
260
+ $.each(gemStats, function(k,stat){
261
+ totalGems++;
262
+ stat.samples = stat.samples.getUnique();
263
+ });
258
264
 
259
265
 
266
+ var gemsSorted = _(gemStats).pairs()
267
+ .sortBy(function(item){
268
+ return -item[1].samples.length;
269
+ })
270
+ .map(function(item){return item[1]})
271
+ .value();
272
+
260
273
  var currentIndex = 0;
261
- $.each(gemStats, function(k,stat){
274
+ _.each(gemsSorted, function(stat){
262
275
 
263
276
  stat.color = rainbow(totalGems, currentIndex);
264
- stat.samples = stat.samples.getUnique();
265
277
 
266
278
  for(var x=0; x < stat.frames.length; x++) {
267
279
  info[stat.frames[x]] = {nodes: [], samples: [], color: stat.color};
@@ -271,6 +283,7 @@ $.each(gemStats, function(k,stat){
271
283
  });
272
284
 
273
285
 
286
+
274
287
  // see: http://bl.ocks.org/mundhradevang/1387786
275
288
  function fontSize(d,i) {
276
289
  var size = yScale(1) / 3;
@@ -335,10 +348,10 @@ for (var r in info) {
335
348
 
336
349
 
337
350
  // render the legend
338
- $.each(gemStats, function(k,v){
351
+ _.each(gemsSorted, function(gem){
339
352
  var node = $("<div></div>")
340
- .css("background-color", v.color)
341
- .text(k + " " + samplePercent(v.samples.length)) ;
353
+ .css("background-color", gem.color)
354
+ .text(gem.name + " " + samplePercent(gem.samples.length)) ;
342
355
  $('.legend').append(node);
343
356
  });
344
357
 
@@ -1,3 +1,3 @@
1
1
  module Flamegraph
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flamegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Saffron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-03 00:00:00.000000000 Z
11
+ date: 2013-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fast_stack
@@ -150,4 +150,3 @@ test_files:
150
150
  - test/test_helper.rb
151
151
  - test/test_renderer.rb
152
152
  - test/test_sampler.rb
153
- has_rdoc: