Class: Profiler::Profile
- Inherits:
-
Object
- Object
- Profiler::Profile
- Defined in:
- lib/profiler/profile.rb
Defined Under Namespace
Classes: ProfilerError
Instance Method Summary collapse
-
#initialize ⇒ Profile
constructor
Initialise redis.
-
#start ⇒ Object
main point.
Constructor Details
#initialize ⇒ Profile
Initialise redis
34 35 36 37 38 39 40 |
# File 'lib/profiler/profile.rb', line 34 def initialize @redis = Redis.new( host: "127.0.0.1", port: 6379, db: 15 ) end |
Instance Method Details
#start ⇒ Object
main point
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/profiler/profile.rb', line 44 def start output = String.new result = RubyProf.profile do yield end printer = RubyProf::FlatPrinter.new(result) printer.print(output, min_percent: 0) @redis.set(:profile, output) nil rescue StandardError => e raise ProfilerError.new e..to_s end |