[Title] fix for ruby 1.8.7
authorHyoun Jiil <jiil.hyoun@samsung.com>
Tue, 30 Jul 2013 09:04:07 +0000 (18:04 +0900)
committerHyoun Jiil <jiil.hyoun@samsung.com>
Tue, 30 Jul 2013 09:04:07 +0000 (18:04 +0900)
[Type] Enhancement
[Module] Toolchain /
[Priority] Major
[Jira#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

Change-Id: I0fe49ead421a6cd2afb3131b9c968b063bd201ad

performance_analyzer

index 2bbf5190181e4ddfcdc10cb2d9e3ed43f9b5aa18..39d82a441d97528e6d4c7dda87d136f4b30fc6f9 100755 (executable)
@@ -2,7 +2,7 @@
 
 =begin
 
- performance_analizer
+ performance_analyzer
 
 Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
 
@@ -28,6 +28,7 @@ Contributors:
 - S-Core Co., Ltd
 =end
 
+require 'rubygems'
 require 'time'
 require 'optparse'
 require 'dbi'
@@ -51,17 +52,17 @@ class CommonJob
                @t_BASE = nil
                t = Time.now
                offset = t.getlocal.gmt_offset
-               @t_S = option[:start_time].to_time - offset if not option[:start_time].nil?
-               @t_IS = option[:INIT_START].to_time - offset if not option[:INIT_START].nil?
-               @t_IE = option[:INIT_END].to_time - offset if not option[:INIT_END].nil?
-               @t_WS = option[:WORK_START].to_time - offset if not option[:WORK_START].nil?
-               @t_RUS = option[:REMOTE_UPLOAD_START].to_time - offset if not option[:REMOTE_UPLOAD_START].nil?
-               @t_RUE = option[:REMOTE_UPLOAD_END].to_time - offset if not option[:REMOTE_UPLOAD_END].nil?
-               @t_RDS = option[:REMOTE_DOWNLOAD_START].to_time - offset if not option[:REMOTE_DOWNLOAD_START].nil?
-               @t_RDE = option[:REMOTE_DOWNLOAD_END].to_time - offset if not option[:REMOTE_DOWNLOAD_END].nil?
-               @t_US = option[:UPLOAD_START].to_time - offset if not option[:UPLOAD_START].nil?
-               @t_UE = option[:UPLOAD_END].to_time - offset if not option[:UPLOAD_END].nil?
-               @t_E = option[:end_time].to_time - offset if not option[:end_time].nil?
+               @t_S = Time.parse(option[:start_time].strftime) - offset if not option[:start_time].nil?
+               @t_IS = Time.parse(option[:INIT_START].strftime) - offset if not option[:INIT_START].nil?
+               @t_IE = Time.parse(option[:INIT_END].strftime) - offset if not option[:INIT_END].nil?
+               @t_WS = Time.parse(option[:WORK_START].strftime) - offset if not option[:WORK_START].nil?
+               @t_RUS = Time.parse(option[:REMOTE_UPLOAD_START].strftime) - offset if not option[:REMOTE_UPLOAD_START].nil?
+               @t_RUE = Time.parse(option[:REMOTE_UPLOAD_END].strftime) - offset if not option[:REMOTE_UPLOAD_END].nil?
+               @t_RDS = Time.parse(option[:REMOTE_DOWNLOAD_START].strftime) - offset if not option[:REMOTE_DOWNLOAD_START].nil?
+               @t_RDE = Time.parse(option[:REMOTE_DOWNLOAD_END].strftime) - offset if not option[:REMOTE_DOWNLOAD_END].nil?
+               @t_US = Time.parse(option[:UPLOAD_START].strftime) - offset if not option[:UPLOAD_START].nil?
+               @t_UE = Time.parse(option[:UPLOAD_END].strftime) - offset if not option[:UPLOAD_END].nil?
+               @t_E = Time.parse(option[:end_time].strftime) - offset if not option[:end_time].nil?
                @sub_job = []
                @d_BASE = 0
                @d_waitI = 0
@@ -105,20 +106,20 @@ class CommonJob
                result = []
                work = 0
                work = @d_WORK if @jtype != "MULTIBUILD"
-               result.push (", " * pre_pending) + @id.to_s + (", " * post_pending) + ", #{@status.to_s}, #{@distribution.to_s}, #{@project.to_s}, #{@supported_os.to_s}, " + [@d_BASE, @d_waitI, @d_INIT, @d_waitW, @d_RU, @d_WORK, @d_RD, @d_waitU, @d_U, @d_FINISH, @d_total, @sub_work_total, @sub_total].map{|x| x.to_s }.join(", ") + ", #{((@d_U + work + @sub_work_total)/(@d_total + @sub_total) * 100).round 2 if (@d_total + @sub_total) > 0}%"
+               result.push "" + (", " * pre_pending) + @id.to_s + (", " * post_pending) + ", #{@status.to_s}, #{@distribution.to_s}, #{@project.to_s}, #{@supported_os.to_s}, " + [@d_BASE, @d_waitI, @d_INIT, @d_waitW, @d_RU, @d_WORK, @d_RD, @d_waitU, @d_U, @d_FINISH, @d_total, @sub_work_total, @sub_total].map{|x| x.to_s }.join(", ") + ", #{((@d_U + work + @sub_work_total)/(@d_total + @sub_total) * 100).round if (@d_total + @sub_total) > 0}%"
                pre_pending = pre_pending +1
                post_pending = post_pending -1
                result = result + sub_job.map{|x| x.print_cvs pre_pending, post_pending }
                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}%"
+               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
        def print_single
-               puts "#{@t_S.to_s}, #{@status.to_s}, #{@distribution.to_s}, #{@project.to_s}, #{@supported_os.to_s}, " + [@d_WORK, @d_U, @sub_work_total, @d_total, @sub_total].map{|x| x.round.to_s }.join(", ") + ", #{((@d_WORK + @d_U + @sub_work_total)/(@d_total + @sub_total) * 100).round if (@d_total + @sub_total) > 0}%"
+               puts "#{@t_S.to_s}, #{@status.to_s}, #{@distribution.to_s}, #{@project.to_s}, #{@supported_os.to_s}, " + [@d_WORK, @d_U, @sub_work_total, @d_total, @sub_total].map{|x| x.round.to_s }.join(", ") + ", #{((@d_WORK + @d_U + @sub_work_total)/(@d_total + @sub_total) * 100).round if (@d_total + @sub_total) > 0}%"
        end
        def print_register
-               puts "#{@t_S.to_s}, #{@status.to_s}, #{@distribution.to_s}, #{@project.to_s}, #{@supported_os.to_s}, " + [@d_WORK, @sub_work_total, @d_total, @sub_total].map{|x| x.round.to_s }.join(", ") + ", #{((@d_WORK + @sub_work_total)/(@d_total + @sub_total) * 100).round if (@d_total + @sub_total) > 0}%"
+               puts "#{@t_S.to_s}, #{@status.to_s}, #{@distribution.to_s}, #{@project.to_s}, #{@supported_os.to_s}, " + [@d_WORK, @sub_work_total, @d_total, @sub_total].map{|x| x.round.to_s }.join(", ") + ", #{((@d_WORK + @sub_work_total)/(@d_total + @sub_total) * 100).round if (@d_total + @sub_total) > 0}%"
        end
 end