Skip to content

Commit

Permalink
Move Lrama::Report::Profile to Lrama::Report::Profile::CallStack
Browse files Browse the repository at this point in the history
  • Loading branch information
yui-knk committed Feb 3, 2025
1 parent eb6e4c5 commit ddca055
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 48 deletions.
2 changes: 1 addition & 1 deletion lib/lrama/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Command

def run(argv)
parser_options(argv)
Lrama::Report::Profile.report_profile(@options.profile_opts[:call_stack]) do
Lrama::Report::Profile::CallStack.report_profile(@options.profile_opts[:call_stack]) do
_run
end
end
Expand Down
31 changes: 1 addition & 30 deletions lib/lrama/report/profile.rb
Original file line number Diff line number Diff line change
@@ -1,32 +1,3 @@
# rbs_inline: enabled
# frozen_string_literal: true

module Lrama
class Report
module Profile
# See "Call-stack Profiling Lrama" in README.md for how to use.
#
# @rbs enabled: bool
# @rbs &: -> void
# @rbs return: StackProf::result | void
def self.report_profile(enabled)
if enabled && require_stackprof
StackProf.run(mode: :cpu, raw: true, out: 'tmp/stackprof-cpu-myapp.dump') do
yield
end
else
yield
end
end

# @rbs return: bool
def self.require_stackprof
require "stackprof"
true
rescue LoadError
warn "stackprof is not installed. Please run `bundle install`."
false
end
end
end
end
require_relative 'profile/call_stack'
34 changes: 34 additions & 0 deletions lib/lrama/report/profile/call_stack.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# rbs_inline: enabled
# frozen_string_literal: true

module Lrama
class Report
module Profile
module CallStack
# See "Call-stack Profiling Lrama" in README.md for how to use.
#
# @rbs enabled: bool
# @rbs &: -> void
# @rbs return: StackProf::result | void
def self.report_profile(enabled)
if enabled && require_stackprof
StackProf.run(mode: :cpu, raw: true, out: 'tmp/stackprof-cpu-myapp.dump') do
yield
end
else
yield
end
end

# @rbs return: bool
def self.require_stackprof
require "stackprof"
true
rescue LoadError
warn "stackprof is not installed. Please run `bundle install`."
false
end
end
end
end
end
17 changes: 0 additions & 17 deletions sig/generated/lrama/report/profile.rbs

This file was deleted.

19 changes: 19 additions & 0 deletions sig/generated/lrama/report/profile/call_stack.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated from lib/lrama/report/profile/call_stack.rb with RBS::Inline

module Lrama
class Report
module Profile
module CallStack
# See "Call-stack Profiling Lrama" in README.md for how to use.
#
# @rbs enabled: bool
# @rbs &: -> void
# @rbs return: StackProf::result | void
def self.report_profile: (bool enabled) { () -> void } -> (StackProf::result | void)

# @rbs return: bool
def self.require_stackprof: () -> bool
end
end
end
end

0 comments on commit ddca055

Please sign in to comment.