Class: Perfer::Session::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/perfer/session.rb

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ DSL

Returns a new instance of DSL.



119
120
121
# File 'lib/perfer/session.rb', line 119

def initialize(session)
  @session = session
end

Instance Method Details

#bench(title, &block) ⇒ Object



141
142
143
# File 'lib/perfer/session.rb', line 141

def bench(title, &block)
  @session.add_job(InputSizeJob, title, &block)
end

#iterate(title, code = nil, data = nil, &block) ⇒ Object



137
138
139
# File 'lib/perfer/session.rb', line 137

def iterate(title, code = nil, data = nil, &block)
  @session.add_job(IterationJob, title, code, data, &block)
end

#measure(&block) ⇒ Object

Raises:



145
146
147
148
# File 'lib/perfer/session.rb', line 145

def measure(&block)
  raise Error, WRONG_MEASURE_USE unless InputSizeJob === @session.current_job
  @session.current_job.last_measurement = Perfer.measure(&block)
end

#metadata(&block) ⇒ Object



127
128
129
130
131
132
133
134
135
# File 'lib/perfer/session.rb', line 127

def (&block)
  if !block
    @session.
  else
    @session. = MetadataSetter.new.tap do ||
      .instance_eval(&block)
    end.to_hash
  end
end

#objectObject



123
124
125
# File 'lib/perfer/session.rb', line 123

def object
  @session
end