Skip to content

Commit

Permalink
Minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
xlymian committed Jun 13, 2010
1 parent f271927 commit 1034ba7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 25 deletions.
21 changes: 8 additions & 13 deletions lib/hansel/formatting/formatting.rb
Expand Up @@ -13,16 +13,12 @@ def csv_formatter
end

def octave_formatter
num_conns = results.first.num_conns rescue nil
res = results
opts, num_conns = options, (res.first.num_conns rescue nil)
file_name = output_filename{ "-#{num_conns.to_s}" }
template = opts.template || File.join( [ File.dirname(__FILE__), '../../..', opts.template_path, 'octave.m.erb' ] )
File.open(file_name, "w+") do |file|
file.puts OctaveFormatter.new(results,
{
:output_file_name => file_name,
:template => options.template ||
File.join( [ File.dirname(__FILE__), '../../..', options.template_path, 'octave.m.erb' ] ),
}
).format
file.puts OctaveFormatter.new(res, { :output_file_name => file_name, :template => template }).format
end
end

Expand All @@ -38,11 +34,10 @@ def formatted_output
end

def output_filename
part = block_given? ? yield : ''
type = { :yaml => 'yml', :csv => 'csv', :octave => 'm' }[options.format.to_sym]
server = results.first.server
port = results.first.port
[File.join([options.output_dir, ("#{server}:#{port}" + part)]), type].join('.')
opts, part = options, (block_given? ? yield : '')
type = { :yaml => 'yml', :csv => 'csv', :octave => 'm' }[opts.format.to_sym]
server, port = (res = results.first) && res.server, res.port
[File.join([opts.output_dir, ("#{server}:#{port}" + part)]), type].join('.')
end
end
end
10 changes: 4 additions & 6 deletions lib/hansel/hansel.rb
Expand Up @@ -36,10 +36,12 @@ def register
# Output the results based on the requested output format
#
def output
if options.format
FileUtils.mkdir_p options.output_dir
opts = options
if opts.format
FileUtils.mkdir_p opts.output_dir
formatted_output
end
@results.clear
end

def status text
Expand All @@ -50,18 +52,14 @@ def status text
# Run httperf from low_rate to high_rate, stepping by rate_step
#
def run
status "starting run..."
while @jobs.length > 0 do
@current_job = @jobs.pop
(@current_job.low_rate.to_i..@current_job.high_rate.to_i).step(@current_job.rate_step.to_i) do |rate|
status "running httperf at rate: #{rate}"
@current_rate = rate
httperf
end
output
@results.clear
end
status "ending run..."
end

def run_server
Expand Down
4 changes: 2 additions & 2 deletions lib/hansel/httperf/httperf.rb
@@ -1,14 +1,15 @@
module HanselCore
module Httperf
def build_httperf_cmd
cookie = @current_job.cookie
httperf_cmd = [
"httperf --hog",
"--server=#{@current_job.server}",
"--port=#{@current_job.port}",
"--uri=#{@current_job.uri}",
"--num-conns=#{@current_job.num_conns}",
"--rate=#{@current_rate}",
@current_job.cookie && "--add-header='Cookie: #{@current_job.cookie}\\n'"
cookie && "--add-header='Cookie: #{cookie}\\n'"
].compact.join ' '
end

Expand All @@ -29,7 +30,6 @@ def httperf
}))
HttperfResultParser.new(pipe).parse(httperf_result)
end
self
end

end
Expand Down
5 changes: 1 addition & 4 deletions lib/hansel/job_queue/job_queue.rb
Expand Up @@ -5,19 +5,16 @@ def jobs
end

def push_job job
job.port = 80 unless job.port
@jobs.push job
end

def pop_job job
@jobs.pop
end

#
# Load jobs from queue
#
def load_job_queue
(YAML.load_file File.join(config_path, 'jobs.yml')).map do |job|
job.merge!({:port => 80}) unless job[:port]
self.push_job(OpenStruct.new job)
end
self
Expand Down

0 comments on commit 1034ba7

Please sign in to comment.