rack-mini-profiler 0.1.10 → 0.1.11.pre

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rack-mini-profiler might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -44,3 +44,6 @@
44
44
  * Added option to disable profiler for the current session (pp=disable / pp=enable)
45
45
  * yajl compatability contributed by Sven Riedel
46
46
 
47
+ 10-August-2012 - Sam
48
+
49
+ * Added basic prepared statement profiling for postgres
@@ -13,6 +13,7 @@ module Rack
13
13
  data = ::File.open(path(key),"rb") {|f| f.read}
14
14
  return Marshal.load data
15
15
  rescue => e
16
+ p e
16
17
  return nil
17
18
  end
18
19
  end
@@ -22,12 +22,9 @@ module Rack
22
22
  end
23
23
 
24
24
  def to_json(*a)
25
- if a[0] == nil
26
- # YAJL doesnt like nil as options
27
- ::JSON.generate( @attributes )
28
- else
29
- ::JSON.generate(@attributes, a[0])
30
- end
25
+ # this does could take in an option hash, but the only interesting there is max_nesting.
26
+ # if this becomes an option we could increase
27
+ ::JSON.generate( @attributes, :max_nesting => 100 )
31
28
  end
32
29
 
33
30
  end
@@ -91,6 +91,23 @@ if SqlPatches.class_exists? "PG::Result"
91
91
  class PG::Connection
92
92
  alias_method :exec_without_profiling, :exec
93
93
  alias_method :async_exec_without_profiling, :async_exec
94
+ alias_method :exec_prepared_without_profiling, :exec_prepared
95
+ alias_method :send_query_prepared_without_profiling, :send_query_prepared
96
+ alias_method :prepare_without_profiling, :prepare
97
+
98
+ def prepare(*args,&blk)
99
+ current = ::Rack::MiniProfiler.current
100
+ return prepare_without_profiling(*args,&blk) unless current
101
+
102
+ @prepare_map ||= {}
103
+ @prepare_map[args[0]] = args[1]
104
+
105
+ # dont leak more than 10k ever
106
+ @prepare_map = {} if @prepare_map.length > 10000
107
+
108
+ prepare_without_profiling(*args,&blk)
109
+
110
+ end
94
111
 
95
112
  def exec(*args,&blk)
96
113
  current = ::Rack::MiniProfiler.current
@@ -104,6 +121,34 @@ if SqlPatches.class_exists? "PG::Result"
104
121
  result
105
122
  end
106
123
 
124
+ def exec_prepared(*args,&blk)
125
+ current = ::Rack::MiniProfiler.current
126
+ return exec_prepared_without_profiling(*args,&blk) unless current
127
+
128
+ start = Time.now
129
+ result = exec_prepared_without_profiling(*args,&blk)
130
+ elapsed_time = ((Time.now - start).to_f * 1000).round(1)
131
+ mapped = args[0]
132
+ mapped = @prepare_map[mapped] || args[0] if @prepare_map
133
+ result.instance_variable_set("@miniprofiler_sql_id", ::Rack::MiniProfiler.record_sql(mapped, elapsed_time))
134
+
135
+ result
136
+ end
137
+
138
+ def send_query_prepared(*args,&blk)
139
+ current = ::Rack::MiniProfiler.current
140
+ return send_query_prepared_without_profiling(*args,&blk) unless current
141
+
142
+ start = Time.now
143
+ result = send_query_prepared_without_profiling(*args,&blk)
144
+ elapsed_time = ((Time.now - start).to_f * 1000).round(1)
145
+ mapped = args[0]
146
+ mapped = @prepare_map[mapped] || args[0] if @prepare_map
147
+ result.instance_variable_set("@miniprofiler_sql_id", ::Rack::MiniProfiler.record_sql(mapped, elapsed_time))
148
+
149
+ result
150
+ end
151
+
107
152
  def async_exec(*args,&blk)
108
153
  current = ::Rack::MiniProfiler.current
109
154
  return exec_without_profiling(*args,&blk) unless current
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rack-mini-profiler"
3
- s.version = "0.1.10"
3
+ s.version = "0.1.11.pre"
4
4
  s.summary = "Profiles loading speed for rack applications."
5
5
  s.authors = ["Aleks Totic","Sam Saffron", "Robin Ward"]
6
6
  s.description = "Page loading speed displayed on every page. Optimize while you develop, performance is a feature."
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-mini-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
5
- prerelease:
4
+ version: 0.1.11.pre
5
+ prerelease: 7
6
6
  platform: ruby
7
7
  authors:
8
8
  - Aleks Totic
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-08-07 00:00:00.000000000 Z
14
+ date: 2012-08-10 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rack
@@ -130,16 +130,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  segments:
132
132
  - 0
133
- hash: -296105007
133
+ hash: -126757873
134
134
  required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  none: false
136
136
  requirements:
137
- - - ! '>='
137
+ - - ! '>'
138
138
  - !ruby/object:Gem::Version
139
- version: '0'
140
- segments:
141
- - 0
142
- hash: -296105007
139
+ version: 1.3.1
143
140
  requirements: []
144
141
  rubyforge_project:
145
142
  rubygems_version: 1.8.24