Module: SmplPrflr

Includes:
Initializers::Base
Defined in:
lib/smpl_prflr/errors.rb,
lib/smpl_prflr.rb,
lib/smpl_prflr/version.rb,
lib/smpl_prflr/constants.rb,
lib/smpl_prflr/initializers/base.rb

Overview

The MIT License (MIT)

Copyright © 2019-2022 Kondratev Ilya

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Modules: Constants, Initializers Classes: ClassProfilerError, Error, LoadResourcesError, ProfilerError

Constant Summary collapse

VERSION =
"0.1.0".freeze

Instance Method Summary collapse

Methods included from Initializers::Base

#initialize_base!

Instance Method Details

#initialize_profiler!Object

Init Profiler

Init Redis

Raises:



37
38
39
40
41
# File 'lib/smpl_prflr.rb', line 37

def initialize_profiler!
  initialize_base!
rescue  SmplPrflr::Error => e
  raise SmplPrflr::ClassProfilerErrore, e.message
end

#pnil

Profile block of your code

Returns:

  • (nil)

Raises:

  • ProfilerError



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/smpl_prflr.rb', line 52

def p
  result = RubyProf.profile do
    yield
  end

  output = String.new
  printer = RubyProf::FlatPrinter.new(result)
  printer.print(output, min_percent: 0)
  @redis.set(:profile, output)

  nil
rescue SmplPrflr::Error => e
  raise SmplPrflr::ClassProfilerErrore.new, e.message
end

#pingString

Returns PONG.

Examples:

PONG

Returns:

  • (String)

    PONG



45
46
47
# File 'lib/smpl_prflr.rb', line 45

def ping
  "PONG"
end