Skip to content
This repository has been archived by the owner on May 10, 2020. It is now read-only.

Commit

Permalink
fixed poor design leading to bad performance
Browse files Browse the repository at this point in the history
  • Loading branch information
neoice committed Jun 11, 2014
1 parent cb9bbcd commit 5ab3294
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion benchmark/apipie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Benchmark.bm do |x|
x.report { $client = ForemanClientPlus.new(ARGV[0]) }
x.report { $hosts = $client.get_all_hosts }
x.report { $all = []; $hosts.each {|host| $all << $client.find_host(host)} }
x.report { $all = []; $hosts.each {|host| $all << $client.fetch_host_details(host)} } # find_host != fetch_host_details
end

puts "Hosts collected: #{$all.length}"
7 changes: 5 additions & 2 deletions lib/foreman_client_plus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ def find_host(name)
h = raw.detect {|each| each['name'] == name}
end

def fetch_host_details(host)
@api.resource(:hosts).action(:show).call(host)['results']
end

def get_all_hosts
raw = @api.resource(:hosts).action(:index).call()['results']
raw.map {|host| host['name']}
@api.resource(:hosts).action(:index).call()['results']
end
end

0 comments on commit 5ab3294

Please sign in to comment.