allocation_tracer 0.5.3 → 0.6.0

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: 4b75d7a7c70008250908b700237fcb5ecadbec3d
4
- data.tar.gz: 26e19b89b9189346d0504f32461bb474af6e1ccf
3
+ metadata.gz: d67c74d74d79cd3fac954e0d989e59e40871d215
4
+ data.tar.gz: 40ea48ef4e9ad9240b978e7a2ec3fcc62c522342
5
5
  SHA512:
6
- metadata.gz: 3a07f2d2af5fa5cb94f466f7ef1401a6aa67ff9e1376443699b859d155de8d030052437394cbff55bad949811e0c003c61f8ee4fe66fde3380cc63a8c2dae904
7
- data.tar.gz: e9780fee59290887fcc22629c0cf29fb3e95124e1d8fbec178c87212705c41f85b988040fdcebe29174a536d580c5213768685a77b6574a49a14483246a06c10
6
+ metadata.gz: c9e6e3a4318f1b875684c096edabd4a3895ce9672209daa069a89b4589ab0146fb5f21dc445515814b4d9fa0f89d1fcefc240722f7e15bdef2c0c5a41eacd2b8
7
+ data.tar.gz: 1316fda93a0207643dd47dc3450988fcd6b0c4b571232217b1b4409b09d70766669111ec694d37acf567820146600b287b16037ae5ee255f0005817c9e6c7cf4
data/README.md CHANGED
@@ -236,6 +236,7 @@ You can access the following pages.
236
236
  * http://host/allocation_tracer/
237
237
  * http://host/allocation_tracer/allocated_count_table
238
238
  * http://host/allocation_tracer/freed_count_table_page
239
+ * http://host/allocation_tracer/lifetime_table
239
240
 
240
241
  ## Contributing
241
242
 
@@ -1,3 +1,3 @@
1
1
  module ObjectSpace::AllocationTracer
2
- VERSION = "0.5.3"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -53,24 +53,38 @@ module Rack
53
53
  count_table_page ObjectSpace::AllocationTracer.freed_count_table
54
54
  end
55
55
 
56
+ def lifetime_table_page
57
+ table = []
58
+ max_age = 0
59
+ ObjectSpace::AllocationTracer.lifetime_table.each{|type, ages|
60
+ max_age = [max_age, ages.size - 1].max
61
+ table << [type, *ages]
62
+ }
63
+ headers = ['type', *(0..max_age)].map{|e| "<th>#{e}</th>"}.join("\n")
64
+ body = table.map{|cols|
65
+ "<tr>" + cols.map{|c| "<td>#{c}</td>"}.join("\n") + "</tr>"
66
+ }.join("\n")
67
+ "<table border='1'><tr>#{headers}</tr>\n#{body}</table>"
68
+ end
69
+
56
70
  def call env
57
71
  if /\A\/allocation_tracer\// =~ env["PATH_INFO"]
58
72
  result = ObjectSpace::AllocationTracer.result
59
73
  ObjectSpace::AllocationTracer.pause
60
74
 
61
- case env["PATH_INFO"]
62
- when /lifetime_table/
63
- raise "Unsupported: lifetime_table"
64
- when /allocated_count_table/
65
- text = allocated_count_table_page
66
- when /freed_count_table/
67
- text = freed_count_table_page
68
- else
69
- text = allocation_trace_page result, env
70
- end
71
-
72
75
  begin
73
- [200, {"Content-Type" => "text/html"}, [text]]
76
+ html = case env["PATH_INFO"]
77
+ when /lifetime_table/
78
+ lifetime_table_page
79
+ when /allocated_count_table/
80
+ allocated_count_table_page
81
+ when /freed_count_table/
82
+ freed_count_table_page
83
+ else
84
+ allocation_trace_page result, env
85
+ end
86
+ #
87
+ [200, {"Content-Type" => "text/html"}, [html]]
74
88
  ensure
75
89
  ObjectSpace::AllocationTracer.resume
76
90
  end
@@ -84,6 +98,7 @@ module Rack
84
98
  def initialize *args
85
99
  super
86
100
  ObjectSpace::AllocationTracer.setup %i(path line class)
101
+ ObjectSpace::AllocationTracer.lifetime_table_setup true
87
102
  ObjectSpace::AllocationTracer.start
88
103
  end
89
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allocation_tracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koichi Sasada
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-15 00:00:00.000000000 Z
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler