Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 1 | # Copyright 2017 Open Networking Foundation (ONF) |
| 2 | # |
| 3 | # Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 4 | # the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 5 | # or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 6 | # |
| 7 | # TestON is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation, either version 2 of the License, or |
| 10 | # (at your option) any later version. |
| 11 | # |
| 12 | # TestON is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 19 | # |
| 20 | # If you have any questions, or if you don't understand R, |
Jeremy Ronquillo | b626884 | 2017-10-03 13:02:58 -0700 | [diff] [blame] | 21 | # please contact Jeremy Ronquillo: j_ronquillo@u.pacific.edu |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 22 | |
| 23 | # ********************************************************** |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 24 | # STEP 1: Data management. |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 25 | # ********************************************************** |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 26 | database_host = 1 |
| 27 | database_port = 2 |
| 28 | database_u_id = 3 |
| 29 | database_pw = 4 |
| 30 | test_name = 5 |
| 31 | branch_name = 6 |
| 32 | old_flow = 7 |
| 33 | save_directory = 8 |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 34 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 35 | print( "**********************************************************" ) |
| 36 | print( "STEP 1: Data management." ) |
| 37 | print( "**********************************************************" ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 38 | |
Jeremy Ronquillo | b626884 | 2017-10-03 13:02:58 -0700 | [diff] [blame] | 39 | # Command line arguments are read. |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 40 | print( "Reading commmand-line args." ) |
| 41 | args <- commandArgs( trailingOnly=TRUE ) |
| 42 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 43 | # ---------------- |
| 44 | # Import Libraries |
| 45 | # ---------------- |
| 46 | |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 47 | print( "Importing libraries." ) |
| 48 | library( ggplot2 ) |
| 49 | library( reshape2 ) |
| 50 | library( RPostgreSQL ) # For databases |
| 51 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 52 | # ------------------- |
| 53 | # Check CLI Arguments |
| 54 | # ------------------- |
| 55 | |
| 56 | print( "Verifying CLI args." ) |
| 57 | |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 58 | if ( is.na( args[ save_directory ] ) ){ |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 59 | |
Jeremy Ronquillo | 9ea85d0 | 2017-11-27 10:21:03 -0800 | [diff] [blame] | 60 | print( paste( "Usage: Rscript SCPFbatchFlowResp.R", |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 61 | "<database-host>", |
| 62 | "<database-port>", |
| 63 | "<database-user-id>", |
| 64 | "<database-password>", |
| 65 | "<test-name>", |
| 66 | "<branch-name>", |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 67 | "<using-old-flow>", |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 68 | "<directory-to-save-graphs>", |
| 69 | sep=" " ) ) |
| 70 | |
Jeremy Ronquillo | 9ea85d0 | 2017-11-27 10:21:03 -0800 | [diff] [blame] | 71 | quit( status = 1 ) # basically exit(), but in R |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 72 | } |
| 73 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 74 | # ----------------- |
| 75 | # Create File Names |
| 76 | # ----------------- |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 77 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 78 | print( "Creating filenames and title of graph." ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 79 | |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 80 | postOutputFile <- paste( args[ save_directory ], |
| 81 | args[ test_name ], |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 82 | "_", |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 83 | args[ branch_name ], |
| 84 | if( args[ old_flow ] == "y" ) "_OldFlow" else "", |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 85 | "_PostGraph.jpg", |
| 86 | sep="" ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 87 | |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 88 | delOutputFile <- paste( args[ save_directory ], |
| 89 | args[ test_name ], |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 90 | "_", |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 91 | args[ branch_name ], |
| 92 | if( args[ old_flow ] == "y" ) "_OldFlow" else "", |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 93 | "_DelGraph.jpg", |
| 94 | sep="" ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 95 | |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 96 | postChartTitle <- paste( "Single Bench Flow Latency - Post\n", |
| 97 | "Last 3 Builds", |
Devin Lim | 1bba762 | 2017-11-14 16:31:41 -0800 | [diff] [blame] | 98 | if( args[ old_flow ] == "y" ) "\nWith Eventually Consistent Flow Rule Store" else "", |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 99 | sep = "" ) |
| 100 | delChartTitle <- paste( "Single Bench Flow Latency - Del\n", |
| 101 | "Last 3 Builds", |
Devin Lim | 1bba762 | 2017-11-14 16:31:41 -0800 | [diff] [blame] | 102 | if( args[ old_flow ] == "y" ) "\nWith Eventually Consistent Flow Rule Store" else "", |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 103 | sep = "" ) |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 104 | |
| 105 | # ------------------ |
| 106 | # SQL Initialization |
| 107 | # ------------------ |
| 108 | |
| 109 | print( "Initializing SQL" ) |
| 110 | |
| 111 | con <- dbConnect( dbDriver( "PostgreSQL" ), |
| 112 | dbname = "onostest", |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 113 | host = args[ database_host ], |
| 114 | port = strtoi( args[ database_port ] ), |
| 115 | user = args[ database_u_id ], |
| 116 | password = args[ database_pw ] ) |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 117 | |
| 118 | # --------------------------- |
| 119 | # Batch Flow Resp SQL Command |
| 120 | # --------------------------- |
| 121 | |
| 122 | print( "Generating Batch Flow Resp SQL Command" ) |
| 123 | |
| 124 | command <- paste( "SELECT * FROM batch_flow_tests WHERE branch='", |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 125 | args[ branch_name ], |
| 126 | "' AND " , |
| 127 | ( if( args[ old_flow ] == 'y' ) "" else "NOT " ) , |
| 128 | "is_old_flow", |
| 129 | " ORDER BY date DESC LIMIT 3", |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 130 | sep="" ) |
| 131 | |
| 132 | print( "Sending SQL command:" ) |
| 133 | print( command ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 134 | |
| 135 | fileData <- dbGetQuery( con, command ) |
| 136 | |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 137 | |
| 138 | # ********************************************************** |
| 139 | # STEP 2: Organize data. |
| 140 | # ********************************************************** |
| 141 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 142 | print( "**********************************************************" ) |
| 143 | print( "STEP 2: Organize Data." ) |
| 144 | print( "**********************************************************" ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 145 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 146 | # ----------------- |
| 147 | # Post Data Sorting |
| 148 | # ----------------- |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 149 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 150 | print( "Sorting data for Post." ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 151 | |
Jeremy Ronquillo | 9ea85d0 | 2017-11-27 10:21:03 -0800 | [diff] [blame] | 152 | requiredColumns <- c( "posttoconfrm", "elapsepost" ) |
| 153 | |
| 154 | tryCatch( postAvgs <- c( fileData[ requiredColumns] ), |
| 155 | error = function( e ) { |
| 156 | print( "[ERROR] One or more expected columns are missing from the data. Please check that the data and SQL command are valid, then try again." ) |
| 157 | print( "Required columns: " ) |
| 158 | print( requiredColumns ) |
| 159 | print( "Actual columns: " ) |
| 160 | print( names( fileData ) ) |
| 161 | print( "Error dump:" ) |
| 162 | print( e ) |
| 163 | quit( status = 1 ) |
| 164 | } |
| 165 | ) |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 166 | |
| 167 | # ------------------------- |
| 168 | # Post Construct Data Frame |
| 169 | # ------------------------- |
| 170 | |
| 171 | postDataFrame <- melt( postAvgs ) |
| 172 | postDataFrame$scale <- fileData$scale |
| 173 | postDataFrame$date <- fileData$date |
| 174 | postDataFrame$iterative <- rev( seq( 1, nrow( fileData ), by = 1 ) ) |
| 175 | |
| 176 | colnames( postDataFrame ) <- c( "ms", |
| 177 | "type", |
| 178 | "scale", |
| 179 | "date", |
| 180 | "iterative" ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 181 | |
| 182 | # Format data frame so that the data is in the same order as it appeared in the file. |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 183 | postDataFrame$type <- as.character( postDataFrame$type ) |
| 184 | postDataFrame$type <- factor( postDataFrame$type, |
| 185 | levels = unique( postDataFrame$type ) ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 186 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 187 | postDataFrame <- na.omit( postDataFrame ) # Omit any data that doesn't exist |
Jeremy Ronquillo | 2d2649d | 2017-09-14 12:53:06 -0700 | [diff] [blame] | 188 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 189 | print( "Post Data Frame Results:" ) |
| 190 | print( postDataFrame ) |
| 191 | |
| 192 | # ---------------- |
| 193 | # Del Data Sorting |
| 194 | # ---------------- |
| 195 | |
Jeremy Ronquillo | 9ea85d0 | 2017-11-27 10:21:03 -0800 | [diff] [blame] | 196 | requiredColumns <- c( "deltoconfrm", "elapsedel" ) |
| 197 | |
| 198 | tryCatch( delAvgs <- c( fileData[ requiredColumns] ), |
| 199 | error = function( e ) { |
| 200 | print( "[ERROR] One or more expected columns are missing from the data. Please check that the data and SQL command are valid, then try again." ) |
| 201 | print( "Required columns: " ) |
| 202 | print( requiredColumns ) |
| 203 | print( "Actual columns: " ) |
| 204 | print( names( fileData ) ) |
| 205 | print( "Error dump:" ) |
| 206 | print( e ) |
| 207 | quit( status = 1 ) |
| 208 | } |
| 209 | ) |
| 210 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 211 | |
| 212 | # ------------------------ |
| 213 | # Del Construct Data Frame |
| 214 | # ------------------------ |
| 215 | |
Jeremy Ronquillo | 9ea85d0 | 2017-11-27 10:21:03 -0800 | [diff] [blame] | 216 | delDataFrame <- melt( delAvgs ) |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 217 | delDataFrame$scale <- fileData$scale |
| 218 | delDataFrame$date <- fileData$date |
| 219 | delDataFrame$iterative <- rev( seq( 1, nrow( fileData ), by = 1 ) ) |
| 220 | |
| 221 | colnames( delDataFrame ) <- c( "ms", |
| 222 | "type", |
| 223 | "scale", |
| 224 | "date", |
| 225 | "iterative" ) |
| 226 | |
| 227 | # Format data frame so that the data is in the same order as it appeared in the file. |
| 228 | delDataFrame$type <- as.character( delDataFrame$type ) |
| 229 | delDataFrame$type <- factor( delDataFrame$type, |
| 230 | levels = unique( delDataFrame$type ) ) |
| 231 | |
| 232 | delDataFrame <- na.omit( delDataFrame ) # Omit any data that doesn't exist |
| 233 | |
| 234 | print( "Del Data Frame Results:" ) |
| 235 | print( delDataFrame ) |
Jeremy Ronquillo | 2d2649d | 2017-09-14 12:53:06 -0700 | [diff] [blame] | 236 | |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 237 | # ********************************************************** |
| 238 | # STEP 3: Generate graphs. |
| 239 | # ********************************************************** |
| 240 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 241 | print( "**********************************************************" ) |
| 242 | print( "STEP 3: Generate Graph." ) |
| 243 | print( "**********************************************************" ) |
| 244 | |
| 245 | # ------------------------------------------ |
| 246 | # Initializing variables used in both graphs |
| 247 | # ------------------------------------------ |
| 248 | |
| 249 | print( "Initializing variables used in both graphs." ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 250 | |
Jeremy Ronquillo | 0e27b91 | 2017-10-21 14:34:24 -0700 | [diff] [blame] | 251 | theme_set( theme_grey( base_size = 22 ) ) # set the default text size of the graph. |
Jeremy Ronquillo | b626884 | 2017-10-03 13:02:58 -0700 | [diff] [blame] | 252 | xLabel <- xlab( "Build Date" ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 253 | yLabel <- ylab( "Latency (ms)" ) |
| 254 | fillLabel <- labs( fill="Type" ) |
Jeremy Ronquillo | 0e27b91 | 2017-10-21 14:34:24 -0700 | [diff] [blame] | 255 | colors <- scale_fill_manual( values=c( "#F77670", "#619DFA" ) ) |
| 256 | wrapLegend <- guides( fill=guide_legend( nrow=1, byrow=TRUE ) ) |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 257 | barWidth <- 0.3 |
| 258 | imageWidth <- 15 |
| 259 | imageHeight <- 10 |
| 260 | imageDPI <- 200 |
| 261 | |
| 262 | theme <- theme( plot.title = element_text( hjust = 0.5, size = 32, face = 'bold' ), |
| 263 | legend.position = "bottom", |
| 264 | legend.text = element_text( size = 22 ), |
| 265 | legend.title = element_blank(), |
Jeremy Ronquillo | 94f99dd | 2018-01-05 11:11:27 -0800 | [diff] [blame] | 266 | legend.key.size = unit( 1.5, 'lines' ), |
| 267 | plot.subtitle = element_text( size=16, hjust=1.0 ) ) |
| 268 | |
| 269 | subtitle <- paste( "Last Updated: ", format( Sys.time(), format = "%b %d, %Y at %I:%M %p %Z" ), sep="" ) |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 270 | |
| 271 | barGraphFormat <- geom_bar( stat = "identity", |
| 272 | width = barWidth ) |
| 273 | |
| 274 | # ----------------------- |
| 275 | # Post Generate Main Plot |
| 276 | # ----------------------- |
| 277 | |
| 278 | print( "Creating main plot for Post graph." ) |
| 279 | |
| 280 | mainPlot <- ggplot( data = postDataFrame, aes( x = iterative, |
| 281 | y = ms, |
| 282 | fill = type ) ) |
| 283 | |
| 284 | # ----------------------------------- |
| 285 | # Post Fundamental Variables Assigned |
| 286 | # ----------------------------------- |
| 287 | |
| 288 | print( "Generating fundamental graph data for Post graph." ) |
| 289 | |
| 290 | xScaleConfig <- scale_x_continuous( breaks = postDataFrame$iterative, |
| 291 | label = postDataFrame$date ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 292 | |
Jeremy Ronquillo | 94f99dd | 2018-01-05 11:11:27 -0800 | [diff] [blame] | 293 | title <- labs( title = postChartTitle, subtitle = subtitle ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 294 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 295 | fundamentalGraphData <- mainPlot + |
| 296 | xScaleConfig + |
| 297 | xLabel + |
| 298 | yLabel + |
| 299 | fillLabel + |
| 300 | theme + |
| 301 | wrapLegend + |
| 302 | colors + |
| 303 | title |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 304 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 305 | # -------------------------------- |
| 306 | # Post Generating Bar Graph Format |
| 307 | # -------------------------------- |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 308 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 309 | print( "Generating bar graph for Post graph." ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 310 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 311 | sum <- fileData[ 'posttoconfrm' ] + |
| 312 | fileData[ 'elapsepost' ] |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 313 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 314 | values <- geom_text( aes( x = postDataFrame$iterative, |
| 315 | y = sum + 0.03 * max( sum ), |
| 316 | label = format( sum, |
| 317 | digits = 3, |
| 318 | big.mark = ",", |
| 319 | scientific = FALSE ) ), |
| 320 | size = 7.0, |
| 321 | fontface = "bold" ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 322 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 323 | result <- fundamentalGraphData + |
| 324 | barGraphFormat + |
| 325 | values |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 326 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 327 | # ---------------------------- |
| 328 | # Post Exporting Graph to File |
| 329 | # ---------------------------- |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 330 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 331 | print( paste( "Saving Post bar chart to", postOutputFile ) ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 332 | |
Jeremy Ronquillo | 9ea85d0 | 2017-11-27 10:21:03 -0800 | [diff] [blame] | 333 | tryCatch( ggsave( postOutputFile, |
| 334 | width = imageWidth, |
| 335 | height = imageHeight, |
| 336 | dpi = imageDPI ), |
| 337 | error = function( e ){ |
| 338 | print( "[ERROR] There was a problem saving the graph due to a graph formatting exception. Error dump:" ) |
| 339 | print( e ) |
| 340 | quit( status = 1 ) |
| 341 | } |
| 342 | ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 343 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 344 | print( paste( "[SUCCESS] Successfully wrote stacked bar chart out to", postOutputFile ) ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 345 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 346 | # ---------------------- |
| 347 | # Del Generate Main Plot |
| 348 | # ---------------------- |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 349 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 350 | print( "Creating main plot for Del graph." ) |
Jeremy Ronquillo | 2d2649d | 2017-09-14 12:53:06 -0700 | [diff] [blame] | 351 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 352 | mainPlot <- ggplot( data = delDataFrame, aes( x = iterative, |
| 353 | y = ms, |
| 354 | fill = type ) ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 355 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 356 | # ---------------------------------- |
| 357 | # Del Fundamental Variables Assigned |
| 358 | # ---------------------------------- |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 359 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 360 | print( "Generating fundamental graph data for Del graph." ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 361 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 362 | xScaleConfig <- scale_x_continuous( breaks = delDataFrame$iterative, |
| 363 | label = delDataFrame$date ) |
Jeremy Ronquillo | 94f99dd | 2018-01-05 11:11:27 -0800 | [diff] [blame] | 364 | |
| 365 | title <- labs( title = delChartTitle, subtitle = subtitle ) |
Jeremy Ronquillo | 2d2649d | 2017-09-14 12:53:06 -0700 | [diff] [blame] | 366 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 367 | fundamentalGraphData <- mainPlot + |
| 368 | xScaleConfig + |
| 369 | xLabel + |
| 370 | yLabel + |
| 371 | fillLabel + |
| 372 | theme + |
| 373 | wrapLegend + |
| 374 | colors + |
| 375 | title |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 376 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 377 | # ------------------------------- |
| 378 | # Del Generating Bar Graph Format |
| 379 | # ------------------------------- |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 380 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 381 | print( "Generating bar graph for Del graph." ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 382 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 383 | sum <- fileData[ 'deltoconfrm' ] + |
| 384 | fileData[ 'elapsedel' ] |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 385 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 386 | values <- geom_text( aes( x = delDataFrame$iterative, |
| 387 | y = sum + 0.03 * max( sum ), |
| 388 | label = format( sum, |
| 389 | digits = 3, |
| 390 | big.mark = ",", |
| 391 | scientific = FALSE ) ), |
| 392 | size = 7.0, |
| 393 | fontface = "bold" ) |
Jeremy Ronquillo | 6df8781 | 2017-08-28 16:17:36 +0000 | [diff] [blame] | 394 | |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 395 | result <- fundamentalGraphData + |
| 396 | barGraphFormat + |
| 397 | title + |
| 398 | values |
| 399 | |
| 400 | # --------------------------- |
| 401 | # Del Exporting Graph to File |
| 402 | # --------------------------- |
| 403 | |
| 404 | print( paste( "Saving Del bar chart to", delOutputFile ) ) |
| 405 | |
Jeremy Ronquillo | 9ea85d0 | 2017-11-27 10:21:03 -0800 | [diff] [blame] | 406 | tryCatch( ggsave( delOutputFile, |
| 407 | width = imageWidth, |
| 408 | height = imageHeight, |
| 409 | dpi = imageDPI ), |
| 410 | error = function( e ){ |
| 411 | print( "[ERROR] There was a problem saving the graph due to a graph formatting exception. Error dump:" ) |
| 412 | print( e ) |
| 413 | quit( status = 1 ) |
| 414 | } |
| 415 | ) |
Jeremy Ronquillo | 7673f80 | 2017-10-30 09:42:44 -0700 | [diff] [blame] | 416 | |
Devin Lim | 0e96716 | 2017-11-03 15:59:53 -0700 | [diff] [blame] | 417 | print( paste( "[SUCCESS] Successfully wrote stacked bar chart out to", delOutputFile ) ) |
Jeremy Ronquillo | 9ea85d0 | 2017-11-27 10:21:03 -0800 | [diff] [blame] | 418 | quit( status = 0 ) |