result = result + sub_job.map{|x| x.print_cvs pre_pending, post_pending }
return result
end
+ def print_xml(pre_pending = 1)
+ result = []
+ result.push "" + ("\t" * pre_pending) + "<testcase classname=\"#{@jtype}\" name=\"#{@id}_#{@project}_#{@supported_os}_total\" time=\"#{@d_total.to_i}\"/>"
+ return result
+ end
def print_multi
puts "#{@t_S.to_s}, #{@status.to_s}, #{@distribution.to_s}, #{@project.to_s}, #{@supported_os.to_s}, " + [ @d_U, @sub_work_total, @d_total, @sub_total].map{|x| x.round.to_s }.join(", ") + ", #{((@d_U + @sub_work_total)/(@d_total + @sub_total) * 100).round if (@d_total + @sub_total) > 0}%"
end
opts.on('-c', '--csv <file>', 'save csv file') do |cvs|
options[:cvs] = cvs
end
+ opts.on('-x', '--xml <file>', 'save xml file') do |xml|
+ options[:xml] = xml
+ end
opts.on('-h', '--help', 'print this message') do |help|
puts "useage: performance_analizer -d \"Mysql:database=<database>;host=<host_ip>;port=<port>\" -u \"<user>\" -p \"<password>\" -w \"start_time >= '2013-07-21'\" -c result.cvs"
puts opts.help
return jobs.select{|j| (names - j.project.split(" ")).empty? }
end
-if option[:cvs].nil? then
- mjobs = name_extractor(multiJobs,option[:name])
- if not mjobs.empty? then
- puts "multi job"
- puts "time, status, branch, project, os, upload, sub_work, total, sub_total, (upload + sub_work)/(total + sub_total)%"
- mjobs.each do |m|
- m.print_multi
- end
- end
-
- sjobs = name_extractor(singleJobs,option[:name])
- if not sjobs.empty? then
- puts "single job"
- puts "time, status, branch, project, os, work, upload, sub_work, total, sub_total, (work + upload + sub_work)/(total + sub_total)%"
- sjobs.each do |s|
- s.print_single
- end
- end
-
- rjobs = name_extractor(registerJobs,option[:name])
- if not rjobs.empty? then
- puts "register job"
- puts "time, status, branch, project, os, upload, sub_work, total, sub_total, (upload + sub_work)/(total + sub_total)%"
- rjobs.each do |r|
- r.print_register
- end
- end
-else
+if not option[:cvs].nil? then
File.open(option[:cvs],"w") do |f|
mjobs = name_extractor(multiJobs,option[:name])
if not mjobs.empty? then
end
end
end
+else
+ if not option[:xml].nil? then
+ File.open(option[:xml],"w") do |f|
+ mjobs = name_extractor(multiJobs,option[:name])
+ if not mjobs.empty? then
+ f.puts "<testsuite error=\"\" failures=\"\" name=\"Multi Build\" skips=\"\" tests=\"#{mjobs.count}\" time=\"#{(mjobs[-1].t_E - mjobs[0].t_S).to_i}\">"
+ mjobs.each do |m|
+ f.puts m.print_xml(1)
+ end
+ f.puts "</testsuite>"
+ end
+ sjobs = name_extractor(singleJobs,option[:name])
+ if not sjobs.empty? then
+ f.puts "single job"
+ f.puts "job, reverse, status, branch, projects, os, start, wait, init, wait, remote upload, work, remote donwload, wait, upload, finish, total, sub work total, sub total, performance (w/t)%"
+ sjobs.each do |m|
+ f.puts m.print_xml()
+ end
+ end
+ rjobs = name_extractor(registerJobs,option[:name])
+ if not rjobs.empty? then
+ f.puts "register job"
+ f.puts "register, reverse, status, branch, projects, os, start, wait, init, wait, remote upload, work, remote donwload, wait, upload, finish, total, sub work total, sub total, performance (w/t)%"
+ rjobs.each do |m|
+ f.puts m.print_xml()
+ end
+ end
+ end
+ else
+ mjobs = name_extractor(multiJobs,option[:name])
+ if not mjobs.empty? then
+ puts "multi job"
+ puts "time, status, branch, project, os, upload, sub_work, total, sub_total, (upload + sub_work)/(total + sub_total)%"
+ mjobs.each do |m|
+ m.print_multi
+ end
+ end
+
+ sjobs = name_extractor(singleJobs,option[:name])
+ if not sjobs.empty? then
+ puts "single job"
+ puts "time, status, branch, project, os, work, upload, sub_work, total, sub_total, (work + upload + sub_work)/(total + sub_total)%"
+ sjobs.each do |s|
+ s.print_single
+ end
+ end
+
+ rjobs = name_extractor(registerJobs,option[:name])
+ if not rjobs.empty? then
+ puts "register job"
+ puts "time, status, branch, project, os, upload, sub_work, total, sub_total, (upload + sub_work)/(total + sub_total)%"
+ rjobs.each do |r|
+ r.print_register
+ end
+ end
+ end
end