Class: Brandish::Application::BenchCommand Private
- Inherits:
-
Object
- Object
- Brandish::Application::BenchCommand
- Includes:
- Commander::Methods
- Defined in:
- lib/brandish/application/bench_command.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The bench command. This builds the project in the set directory, and benchmarks. This is for debugging.
Constant Summary collapse
- DEFAULTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
The default options for the build command.
{ only: :all, path: "profile", name: "default" }.freeze
Class Method Summary collapse
-
.call(application, options) ⇒ void
private
Performs the build command.
-
.define(application, command) ⇒ void
private
Defines the command on the given application.
Instance Method Summary collapse
-
#call ⇒ void
private
Performs the build.
-
#initialize(application, options) ⇒ BenchCommand
constructor
private
Initialize the build command.
Constructor Details
#initialize(application, options) ⇒ BenchCommand
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize the build command.
45 46 47 48 |
# File 'lib/brandish/application/bench_command.rb', line 45 def initialize(application, ) @application = application @options = DEFAULTS.merge() end |
Class Method Details
.call(application, options) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Performs the build command. This initializes the command, and calls #call.
38 39 40 |
# File 'lib/brandish/application/bench_command.rb', line 38 def self.call(application, ) new(application, ).call end |
.define(application, command) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Defines the command on the given application. This sets the important data information for the command, for use for the help output.
17 18 19 20 21 22 23 24 |
# File 'lib/brandish/application/bench_command.rb', line 17 def self.define(application, command) command.syntax = "brandish build" command.option "-o", "--only NAMES", [::String] command.option "-p", "--path PATH", ::String command.option "-n", "--name NAME", ::String command.action { |_, o| call(application, o.__hash__) } end |
Instance Method Details
#call ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Performs the build. First, it loads the configuration file for the
build. Then, it performs the build, calling Configure#build with
the :only
filter provided by the options. This uses a Commander
native called progress
to make it look nice on the output.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/brandish/application/bench_command.rb', line 56 def call require "ruby-prof" require "benchmark" @configure = @application.load_configuration_file @path = ::Pathname.new(@options[:path]).(Dir.pwd) @path.mkpath say "=> Beginning build..." result = nil time = Benchmark.measure { result = RubyProf.profile { perform_build } } say "-> Build ended, time: #{time}" say "=> Outputting profile..." result.eliminate_methods!(method_eleminations) output_profile(result) end |