[Title] add xml format printer in performance analyzer
authorHyoun Jiil <jiil.hyoun@samsung.com>
Mon, 9 Sep 2013 09:21:06 +0000 (18:21 +0900)
committerHyoun Jiil <jiil.hyoun@samsung.com>
Mon, 9 Sep 2013 09:21:06 +0000 (18:21 +0900)
[Type] Feature
[Module] Toolchain /
[Priority] Minor
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I8f60df0cb434d4bba1f5bd96be7de09fd6196c85

test/performance_analyzer

index a4b75cde3b4a0b32e911a466b61a6f7cb54153e6..c92fe177ef5f0a14265ba83b0590e98c62eabc3e 100755 (executable)
@@ -112,6 +112,11 @@ class CommonJob
                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
@@ -148,6 +153,9 @@ def option_parse
                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
@@ -297,34 +305,7 @@ def name_extractor(jobs, names)
        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
@@ -351,4 +332,60 @@ else
                        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