rack-mini-profiler 0.1.31 → 0.9.3

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.

Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +149 -0
  3. data/README.md +285 -0
  4. data/{Ruby/lib → lib}/html/includes.css +15 -4
  5. data/{Ruby/lib → lib}/html/includes.js +95 -59
  6. data/{Ruby/lib → lib}/html/includes.less +21 -5
  7. data/{Ruby/lib → lib}/html/includes.tmpl +50 -50
  8. data/{Ruby/lib → lib}/html/jquery.1.7.1.js +0 -0
  9. data/{Ruby/lib → lib}/html/jquery.tmpl.js +0 -0
  10. data/{Ruby/lib → lib}/html/list.css +2 -2
  11. data/{Ruby/lib → lib}/html/list.js +1 -1
  12. data/lib/html/list.tmpl +34 -0
  13. data/lib/html/profile_handler.js +1 -0
  14. data/{Ruby/lib → lib}/html/share.html +2 -2
  15. data/lib/mini_profiler/asset_version.rb +5 -0
  16. data/{Ruby/lib → lib}/mini_profiler/client_settings.rb +3 -3
  17. data/lib/mini_profiler/config.rb +65 -0
  18. data/{Ruby/lib → lib}/mini_profiler/context.rb +0 -0
  19. data/lib/mini_profiler/gc_profiler.rb +181 -0
  20. data/{Ruby/lib → lib}/mini_profiler/profiler.rb +120 -96
  21. data/{Ruby/lib → lib}/mini_profiler/profiling_methods.rb +15 -17
  22. data/{Ruby/lib → lib}/mini_profiler/storage/abstract_store.rb +0 -0
  23. data/{Ruby/lib → lib}/mini_profiler/storage/file_store.rb +30 -8
  24. data/{Ruby/lib → lib}/mini_profiler/storage/memcache_store.rb +5 -7
  25. data/lib/mini_profiler/storage/memory_store.rb +115 -0
  26. data/{Ruby/lib → lib}/mini_profiler/storage/redis_store.rb +19 -11
  27. data/lib/mini_profiler/timer_struct/base.rb +33 -0
  28. data/lib/mini_profiler/timer_struct/client.rb +89 -0
  29. data/lib/mini_profiler/timer_struct/custom.rb +22 -0
  30. data/lib/mini_profiler/timer_struct/page.rb +62 -0
  31. data/lib/mini_profiler/timer_struct/request.rb +126 -0
  32. data/lib/mini_profiler/timer_struct/sql.rb +59 -0
  33. data/lib/mini_profiler/version.rb +5 -0
  34. data/{Ruby/lib → lib}/mini_profiler_rails/railtie.rb +23 -6
  35. data/lib/patches/db/activerecord.rb +42 -0
  36. data/lib/patches/db/moped.rb +12 -0
  37. data/lib/patches/db/mysql2.rb +30 -0
  38. data/lib/patches/db/pg.rb +104 -0
  39. data/lib/patches/db/plucky.rb +47 -0
  40. data/lib/patches/db/rsolr.rb +24 -0
  41. data/lib/patches/db/sequel.rb +10 -0
  42. data/{Ruby/lib → lib}/patches/net_patches.rb +0 -0
  43. data/lib/patches/sql_patches.rb +46 -0
  44. data/lib/rack-mini-profiler.rb +35 -0
  45. data/rack-mini-profiler.gemspec +28 -16
  46. metadata +171 -52
  47. data/Ruby/CHANGELOG +0 -161
  48. data/Ruby/README.md +0 -172
  49. data/Ruby/lib/html/list.tmpl +0 -34
  50. data/Ruby/lib/html/profile_handler.js +0 -1
  51. data/Ruby/lib/mini_profiler/client_timer_struct.rb +0 -78
  52. data/Ruby/lib/mini_profiler/config.rb +0 -58
  53. data/Ruby/lib/mini_profiler/custom_timer_struct.rb +0 -22
  54. data/Ruby/lib/mini_profiler/gc_profiler.rb +0 -107
  55. data/Ruby/lib/mini_profiler/gc_profiler_ruby_head.rb +0 -40
  56. data/Ruby/lib/mini_profiler/page_timer_struct.rb +0 -58
  57. data/Ruby/lib/mini_profiler/request_timer_struct.rb +0 -115
  58. data/Ruby/lib/mini_profiler/sql_timer_struct.rb +0 -58
  59. data/Ruby/lib/mini_profiler/storage/memory_store.rb +0 -65
  60. data/Ruby/lib/mini_profiler/timer_struct.rb +0 -33
  61. data/Ruby/lib/mini_profiler/version.rb +0 -5
  62. data/Ruby/lib/patches/sql_patches.rb +0 -277
  63. data/Ruby/lib/rack-mini-profiler.rb +0 -7
@@ -0,0 +1,22 @@
1
+ module Rack
2
+ class MiniProfiler
3
+ module TimerStruct
4
+ # Timing system for a custom timers such as cache, redis, RPC, external API
5
+ # calls, etc.
6
+ class Custom < TimerStruct::Base
7
+ def initialize(type, duration_ms, page, parent)
8
+ @parent = parent
9
+ @page = page
10
+ @type = type
11
+ start_millis = ((Time.now.to_f * 1000).to_i - page[:started]) - duration_ms
12
+ super(
13
+ :type => type,
14
+ :start_milliseconds => start_millis,
15
+ :duration_milliseconds => duration_ms,
16
+ :parent_timing_id => nil
17
+ )
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,62 @@
1
+ module Rack
2
+ class MiniProfiler
3
+ module TimerStruct
4
+
5
+ # TimerStruct::Page
6
+ # Root: TimerStruct::Request
7
+ # :has_many TimerStruct::Request children
8
+ # :has_many TimerStruct::Sql children
9
+ # :has_many TimerStruct::Custom children
10
+ class Page < TimerStruct::Base
11
+ def initialize(env)
12
+ timer_id = MiniProfiler.generate_id
13
+ page_name = env['PATH_INFO']
14
+ started_at = (Time.now.to_f * 1000).to_i
15
+ machine_name = env['SERVER_NAME']
16
+ super(
17
+ :id => timer_id,
18
+ :name => page_name,
19
+ :started => started_at,
20
+ :machine_name => machine_name,
21
+ :level => 0,
22
+ :user => "unknown user",
23
+ :has_user_viewed => false,
24
+ :client_timings => nil,
25
+ :duration_milliseconds => 0,
26
+ :has_trivial_timings => true,
27
+ :has_all_trivial_timings => false,
28
+ :trivial_duration_threshold_milliseconds => 2,
29
+ :head => nil,
30
+ :duration_milliseconds_in_sql => 0,
31
+ :has_sql_timings => true,
32
+ :has_duplicate_sql_timings => false,
33
+ :executed_readers => 0,
34
+ :executed_scalars => 0,
35
+ :executed_non_queries => 0,
36
+ :custom_timing_names => [],
37
+ :custom_timing_stats => {}
38
+ )
39
+ name = "#{env['REQUEST_METHOD']} http://#{env['SERVER_NAME']}:#{env['SERVER_PORT']}#{env['SCRIPT_NAME']}#{env['PATH_INFO']}"
40
+ self[:root] = TimerStruct::Request.createRoot(name, self)
41
+ end
42
+
43
+ def duration_ms
44
+ @attributes[:root][:duration_milliseconds]
45
+ end
46
+
47
+ def root
48
+ @attributes[:root]
49
+ end
50
+
51
+ def to_json(*a)
52
+ attribs = @attributes.merge(
53
+ :started => '/Date(%d)/' % @attributes[:started],
54
+ :duration_milliseconds => @attributes[:root][:duration_milliseconds],
55
+ :custom_timing_names => @attributes[:custom_timing_stats].keys.sort
56
+ )
57
+ ::JSON.generate(attribs, :max_nesting => 100)
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,126 @@
1
+ module Rack
2
+ class MiniProfiler
3
+ module TimerStruct
4
+ class Request < TimerStruct::Base
5
+
6
+ def self.createRoot(name, page)
7
+ TimerStruct::Request.new(name, page, nil).tap do |timer|
8
+ timer[:is_root] = true
9
+ end
10
+ end
11
+
12
+ attr_accessor :children_duration
13
+
14
+ def initialize(name, page, parent)
15
+ start_millis = (Time.now.to_f * 1000).to_i - page[:started]
16
+ depth = parent ? parent.depth + 1 : 0
17
+ super(
18
+ :id => MiniProfiler.generate_id,
19
+ :name => name,
20
+ :duration_milliseconds => 0,
21
+ :duration_without_children_milliseconds => 0,
22
+ :start_milliseconds => start_millis,
23
+ :parent_timing_id => nil,
24
+ :children => [],
25
+ :has_children => false,
26
+ :key_values => nil,
27
+ :has_sql_timings => false,
28
+ :has_duplicate_sql_timings => false,
29
+ :trivial_duration_threshold_milliseconds => 2,
30
+ :sql_timings => [],
31
+ :sql_timings_duration_milliseconds => 0,
32
+ :is_trivial => false,
33
+ :is_root => false,
34
+ :depth => depth,
35
+ :executed_readers => 0,
36
+ :executed_scalars => 0,
37
+ :executed_non_queries => 0,
38
+ :custom_timing_stats => {},
39
+ :custom_timings => {}
40
+ )
41
+ @children_duration = 0
42
+ @start = Time.now
43
+ @parent = parent
44
+ @page = page
45
+ end
46
+
47
+ def duration_ms
48
+ self[:duration_milliseconds]
49
+ end
50
+
51
+ def start_ms
52
+ self[:start_milliseconds]
53
+ end
54
+
55
+ def start
56
+ @start
57
+ end
58
+
59
+ def depth
60
+ self[:depth]
61
+ end
62
+
63
+ def children
64
+ self[:children]
65
+ end
66
+
67
+ def custom_timings
68
+ self[:custom_timings]
69
+ end
70
+
71
+ def sql_timings
72
+ self[:sql_timings]
73
+ end
74
+
75
+ def add_child(name)
76
+ TimerStruct::Request.new(name, @page, self).tap do |timer|
77
+ self[:children].push(timer)
78
+ self[:has_children] = true
79
+ timer[:parent_timing_id] = self[:id]
80
+ timer[:depth] = self[:depth] + 1
81
+ end
82
+ end
83
+
84
+ def add_sql(query, elapsed_ms, page, skip_backtrace = false, full_backtrace = false)
85
+ TimerStruct::Sql.new(query, elapsed_ms, page, self , skip_backtrace, full_backtrace).tap do |timer|
86
+ self[:sql_timings].push(timer)
87
+ timer[:parent_timing_id] = self[:id]
88
+ self[:has_sql_timings] = true
89
+ self[:sql_timings_duration_milliseconds] += elapsed_ms
90
+ page[:duration_milliseconds_in_sql] += elapsed_ms
91
+ end
92
+ end
93
+
94
+ def add_custom(type, elapsed_ms, page)
95
+ TimerStruct::Custom.new(type, elapsed_ms, page, self).tap do |timer|
96
+ timer[:parent_timing_id] = self[:id]
97
+
98
+ self[:custom_timings][type] ||= []
99
+ self[:custom_timings][type].push(timer)
100
+
101
+ self[:custom_timing_stats][type] ||= {:count => 0, :duration => 0.0}
102
+ self[:custom_timing_stats][type][:count] += 1
103
+ self[:custom_timing_stats][type][:duration] += elapsed_ms
104
+
105
+ page[:custom_timing_stats][type] ||= {:count => 0, :duration => 0.0}
106
+ page[:custom_timing_stats][type][:count] += 1
107
+ page[:custom_timing_stats][type][:duration] += elapsed_ms
108
+ end
109
+ end
110
+
111
+ def record_time(milliseconds = nil)
112
+ milliseconds ||= (Time.now - @start) * 1000
113
+ self[:duration_milliseconds] = milliseconds
114
+ self[:is_trivial] = true if milliseconds < self[:trivial_duration_threshold_milliseconds]
115
+ self[:duration_without_children_milliseconds] = milliseconds - @children_duration
116
+
117
+ if @parent
118
+ @parent.children_duration += milliseconds
119
+ end
120
+
121
+ end
122
+
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,59 @@
1
+ module Rack
2
+ class MiniProfiler
3
+
4
+ # Timing system for a SQL query
5
+ module TimerStruct
6
+ class Sql < TimerStruct::Base
7
+ def initialize(query, duration_ms, page, parent, skip_backtrace = false, full_backtrace = false)
8
+
9
+ stack_trace = nil
10
+ unless skip_backtrace || duration_ms < Rack::MiniProfiler.config.backtrace_threshold_ms
11
+ # Allow us to filter the stack trace
12
+ stack_trace = ""
13
+ # Clean up the stack trace if there are options to do so
14
+ Kernel.caller.each do |ln|
15
+ ln.gsub!(Rack::MiniProfiler.config.backtrace_remove, '') if Rack::MiniProfiler.config.backtrace_remove and !full_backtrace
16
+ if full_backtrace or
17
+ (
18
+ (
19
+ Rack::MiniProfiler.config.backtrace_includes.nil? or
20
+ Rack::MiniProfiler.config.backtrace_includes.all?{|regex| ln =~ regex}
21
+ ) and
22
+ (
23
+ Rack::MiniProfiler.config.backtrace_ignores.nil? or
24
+ Rack::MiniProfiler.config.backtrace_ignores.all?{|regex| !(ln =~ regex)}
25
+ )
26
+ )
27
+ stack_trace << ln << "\n"
28
+ end
29
+ end
30
+ end
31
+
32
+ @parent = parent
33
+ @page = page
34
+ start_millis = ((Time.now.to_f * 1000).to_i - page[:started]) - duration_ms
35
+ super(
36
+ :execute_type => 3, # TODO
37
+ :formatted_command_string => query,
38
+ :stack_trace_snippet => stack_trace,
39
+ :start_milliseconds => start_millis,
40
+ :duration_milliseconds => duration_ms,
41
+ :first_fetch_duration_milliseconds => duration_ms,
42
+ :parameters => nil,
43
+ :parent_timing_id => nil,
44
+ :is_duplicate => false
45
+ )
46
+ end
47
+
48
+ def report_reader_duration(elapsed_ms)
49
+ return if @reported
50
+ @reported = true
51
+ self[:duration_milliseconds] += elapsed_ms
52
+ @parent[:sql_timings_duration_milliseconds] += elapsed_ms
53
+ @page[:duration_milliseconds_in_sql] += elapsed_ms
54
+ end
55
+
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,5 @@
1
+ module Rack
2
+ class MiniProfiler
3
+ VERSION = '0.9.3'
4
+ end
5
+ end
@@ -4,9 +4,15 @@ module Rack::MiniProfilerRails
4
4
 
5
5
  # call direct if needed to do a defer init
6
6
  def self.initialize!(app)
7
+
8
+ raise "MiniProfilerRails initialized twice. Set `require: false' for rack-mini-profiler in your Gemfile" if @already_initialized
9
+
7
10
  c = Rack::MiniProfiler.config
8
11
 
9
12
  # By default, only show the MiniProfiler in development mode, in production allow profiling if post_authorize_cb is set
13
+ #
14
+ # NOTE: this must be set here with = and not ||=
15
+ # The out of the box default is "true"
10
16
  c.pre_authorize_cb = lambda { |env|
11
17
  !Rails.env.test?
12
18
  }
@@ -14,16 +20,21 @@ module Rack::MiniProfilerRails
14
20
  c.skip_paths ||= []
15
21
 
16
22
  if Rails.env.development?
17
- c.skip_paths << "/assets/"
23
+ c.skip_paths << app.config.assets.prefix if app.respond_to? :assets
18
24
  c.skip_schema_queries = true
19
25
  end
20
26
 
21
- if Rails.env.production?
27
+ unless Rails.env.development? || Rails.env.test?
22
28
  c.authorization_mode = :whitelist
23
29
  end
24
30
 
31
+ if Rails.logger
32
+ c.logger = Rails.logger
33
+ end
34
+
25
35
  # The file store is just so much less flaky
26
- tmp = Rails.root.to_s + "/tmp/miniprofiler"
36
+ base_path = Rails.application.config.paths['tmp'].first rescue "#{Rails.root}/tmp"
37
+ tmp = base_path + '/miniprofiler'
27
38
  FileUtils.mkdir_p(tmp) unless File.exists?(tmp)
28
39
 
29
40
  c.storage_options = {:path => tmp}
@@ -32,14 +43,20 @@ module Rack::MiniProfilerRails
32
43
  # Quiet the SQL stack traces
33
44
  c.backtrace_remove = Rails.root.to_s + "/"
34
45
  c.backtrace_includes = [/^\/?(app|config|lib|test)/]
35
- c.skip_schema_queries = Rails.env != 'production'
46
+ c.skip_schema_queries = (Rails.env.development? || Rails.env.test?)
36
47
 
37
48
  # Install the Middleware
38
49
  app.middleware.insert(0, Rack::MiniProfiler)
39
50
 
40
51
  # Attach to various Rails methods
41
- ::Rack::MiniProfiler.profile_method(ActionController::Base, :process) {|action| "Executing action: #{action}"}
42
- ::Rack::MiniProfiler.profile_method(ActionView::Template, :render) {|x,y| "Rendering: #{@virtual_path}"}
52
+ ActiveSupport.on_load(:action_controller) do
53
+ ::Rack::MiniProfiler.profile_method(ActionController::Base, :process) {|action| "Executing action: #{action}"}
54
+ end
55
+ ActiveSupport.on_load(:action_view) do
56
+ ::Rack::MiniProfiler.profile_method(ActionView::Template, :render) {|x,y| "Rendering: #{@virtual_path}"}
57
+ end
58
+
59
+ @already_initialized = true
43
60
  end
44
61
 
45
62
  class Railtie < ::Rails::Railtie
@@ -0,0 +1,42 @@
1
+ ## based off https://github.com/newrelic/rpm/blob/master/lib/new_relic/agent/instrumentation/active_record.rb
2
+ ## fallback for alls sorts of weird dbs
3
+ module Rack
4
+ class MiniProfiler
5
+ module ActiveRecordInstrumentation
6
+ def self.included(instrumented_class)
7
+ instrumented_class.class_eval do
8
+ unless instrumented_class.method_defined?(:log_without_miniprofiler)
9
+ alias_method :log_without_miniprofiler, :log
10
+ alias_method :log, :log_with_miniprofiler
11
+ protected :log
12
+ end
13
+ end
14
+ end
15
+
16
+ def log_with_miniprofiler(*args, &block)
17
+ return log_without_miniprofiler(*args, &block) unless SqlPatches.should_measure?
18
+
19
+ sql, name, _binds = args
20
+ start = Time.now
21
+ rval = log_without_miniprofiler(*args, &block)
22
+
23
+ # Don't log schema queries if the option is set
24
+ return rval if Rack::MiniProfiler.config.skip_schema_queries and name =~ /SCHEMA/
25
+
26
+ elapsed_time = SqlPatches.elapsed_time(start)
27
+ Rack::MiniProfiler.record_sql(sql, elapsed_time)
28
+ rval
29
+ end
30
+ end
31
+ end
32
+
33
+ def self.insert_instrumentation
34
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
35
+ include ::Rack::MiniProfiler::ActiveRecordInstrumentation
36
+ end
37
+ end
38
+
39
+ if defined?(::Rails) && !SqlPatches.patched?
40
+ insert_instrumentation
41
+ end
42
+ end
@@ -0,0 +1,12 @@
1
+ # Mongoid 3 patches
2
+ class Moped::Node
3
+ alias_method :process_without_profiling, :process
4
+ def process(*args,&blk)
5
+ return process_without_profiling(*args,&blk) unless SqlPatches.should_measure?
6
+
7
+ result, _record = SqlPatches.record_sql(args[0].log_inspect) do
8
+ process_without_profiling(*args, &blk)
9
+ end
10
+ return result
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ # The best kind of instrumentation is in the actual db provider, however we don't want to double instrument
2
+
3
+ class Mysql2::Result
4
+ alias_method :each_without_profiling, :each
5
+ def each(*args, &blk)
6
+ return each_without_profiling(*args, &blk) unless @miniprofiler_sql_id
7
+
8
+ start = Time.now
9
+ result = each_without_profiling(*args,&blk)
10
+ elapsed_time = SqlPatches.elapsed_time(start)
11
+
12
+ @miniprofiler_sql_id.report_reader_duration(elapsed_time)
13
+ result
14
+ end
15
+ end
16
+
17
+ class Mysql2::Client
18
+ alias_method :query_without_profiling, :query
19
+ def query(*args,&blk)
20
+ return query_without_profiling(*args,&blk) unless SqlPatches.should_measure?
21
+
22
+ result, record = SqlPatches.record_sql( args[0] ) do
23
+ query_without_profiling(*args,&blk)
24
+ end
25
+ result.instance_variable_set("@miniprofiler_sql_id", record) if result
26
+ result
27
+ end
28
+ end
29
+
30
+ SqlPatches.patched = true
@@ -0,0 +1,104 @@
1
+ # PG patches, keep in mind exec and async_exec have a exec{|r| } semantics that is yet to be implemented
2
+ class PG::Result
3
+ alias_method :each_without_profiling, :each
4
+ alias_method :values_without_profiling, :values
5
+
6
+ def values(*args, &blk)
7
+ return values_without_profiling(*args, &blk) unless @miniprofiler_sql_id
8
+ mp_report_sql do
9
+ values_without_profiling(*args ,&blk)
10
+ end
11
+ end
12
+
13
+ def each(*args, &blk)
14
+ return each_without_profiling(*args, &blk) unless @miniprofiler_sql_id
15
+ mp_report_sql do
16
+ each_without_profiling(*args, &blk)
17
+ end
18
+ end
19
+
20
+ def mp_report_sql(&block)
21
+ start = Time.now
22
+ result = yield
23
+ elapsed_time = SqlPatches.elapsed_time(start)
24
+ @miniprofiler_sql_id.report_reader_duration(elapsed_time)
25
+ result
26
+ end
27
+ end
28
+
29
+ class PG::Connection
30
+ alias_method :exec_without_profiling, :exec
31
+ alias_method :async_exec_without_profiling, :async_exec
32
+ alias_method :exec_prepared_without_profiling, :exec_prepared
33
+ alias_method :send_query_prepared_without_profiling, :send_query_prepared
34
+ alias_method :prepare_without_profiling, :prepare
35
+
36
+ def prepare(*args,&blk)
37
+ # we have no choice but to do this here,
38
+ # if we do the check for profiling first, our cache may miss critical stuff
39
+
40
+ @prepare_map ||= {}
41
+ @prepare_map[args[0]] = args[1]
42
+ # dont leak more than 10k ever
43
+ @prepare_map = {} if @prepare_map.length > 1000
44
+
45
+ return prepare_without_profiling(*args,&blk) unless SqlPatches.should_measure?
46
+ prepare_without_profiling(*args,&blk)
47
+ end
48
+
49
+ def exec(*args,&blk)
50
+ return exec_without_profiling(*args,&blk) unless SqlPatches.should_measure?
51
+
52
+ start = Time.now
53
+ result = exec_without_profiling(*args,&blk)
54
+ elapsed_time = SqlPatches.elapsed_time(start)
55
+ record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
56
+ result.instance_variable_set("@miniprofiler_sql_id", record) if result
57
+
58
+ result
59
+ end
60
+
61
+ def exec_prepared(*args,&blk)
62
+ return exec_prepared_without_profiling(*args,&blk) unless SqlPatches.should_measure?
63
+
64
+ start = Time.now
65
+ result = exec_prepared_without_profiling(*args,&blk)
66
+ elapsed_time = SqlPatches.elapsed_time(start)
67
+ mapped = args[0]
68
+ mapped = @prepare_map[mapped] || args[0] if @prepare_map
69
+ record = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time)
70
+ result.instance_variable_set("@miniprofiler_sql_id", record) if result
71
+
72
+ result
73
+ end
74
+
75
+ def send_query_prepared(*args,&blk)
76
+ return send_query_prepared_without_profiling(*args,&blk) unless SqlPatches.should_measure?
77
+
78
+ start = Time.now
79
+ result = send_query_prepared_without_profiling(*args,&blk)
80
+ elapsed_time = SqlPatches.elapsed_time(start)
81
+ mapped = args[0]
82
+ mapped = @prepare_map[mapped] || args[0] if @prepare_map
83
+ record = ::Rack::MiniProfiler.record_sql(mapped, elapsed_time)
84
+ result.instance_variable_set("@miniprofiler_sql_id", record) if result
85
+
86
+ result
87
+ end
88
+
89
+ def async_exec(*args,&blk)
90
+ return exec_without_profiling(*args,&blk) unless SqlPatches.should_measure?
91
+
92
+ start = Time.now
93
+ result = exec_without_profiling(*args,&blk)
94
+ elapsed_time = SqlPatches.elapsed_time(start)
95
+ record = ::Rack::MiniProfiler.record_sql(args[0], elapsed_time)
96
+ result.instance_variable_set("@miniprofiler_sql_id", record) if result
97
+
98
+ result
99
+ end
100
+
101
+ alias_method :query, :exec
102
+ end
103
+
104
+ SqlPatches.patched = true