Created
March 10, 2015 19:14
-
-
Save RX14/562f0577a7bb0bf22ceb to your computer and use it in GitHub Desktop.
gradle-domain-debug.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
#USAGE: ./gradle-domain-debug.rb <gradle --debug log file> | |
#EXAMPLE: ./gradle-domain-debug.rb .gradle/gradle.log | |
require "uri" | |
require "time" | |
file = File.new(ARGV[0]) | |
results = [] | |
file.each_line do |line| | |
if line.include? "[org.gradle.internal.resource.transport.http.HttpClientHelper] Performing" | |
$start = Time.parse(line[0..12]) | |
$url = URI.extract(line, /http(s)?/)[0] | |
end | |
if line.include? "[org.apache.http.impl.conn.DefaultClientConnection] Receiving response" | |
results << { | |
url: $url, | |
start: $start, | |
end: Time.parse(line[0..12]) | |
} | |
end | |
end | |
results.map do |result| | |
result[:time] = result[:end].to_f - result[:start].to_f | |
end | |
results_by_domain = Hash.new([]) | |
results.map do |result| | |
results_by_domain[URI.parse(result[:url]).host] += [result] | |
end | |
puts "#{"domain".ljust(25)}\ttotal time\t\treqs\taverage" | |
results_by_domain.map do |domain, times| | |
sum = times.inject(0.0){ |sum, el| sum + el[:time] } | |
puts "#{domain.ljust(25)}\t#{sum}\t#{times.size}\t#{sum / times.size}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment