github.com/dmaizel/tests@v0.0.0-20210728163746-cae6a2d9cee8/metrics/report/report_dockerfile/dut-details.R (about) 1 #!/usr/bin/env Rscript 2 # Copyright (c) 2018 Intel Corporation 3 # 4 # SPDX-License-Identifier: Apache-2.0 5 6 # Display details for the 'Device Under Test', for all data sets being processed. 7 8 suppressMessages(suppressWarnings(library(tidyr))) # for gather(). 9 library(tibble) 10 suppressMessages(suppressWarnings(library(plyr))) # rbind.fill 11 # So we can plot multiple graphs 12 library(gridExtra) # together. 13 suppressMessages(suppressWarnings(library(ggpubr))) # for ggtexttable. 14 suppressMessages(library(jsonlite)) # to load the data. 15 16 # A list of all the known results files we might find the information inside. 17 resultsfiles=c( 18 "boot-times.json", 19 "footprint-busybox-ksm.json", 20 "footprint-elasticsearch-ksm.json", 21 "footprint-mysql-ksm.json", 22 "memory-footprint.json", 23 "memory-footprint-ksm.json", 24 "fio-randread-16k.json", 25 "fio-randread-32k.json", 26 "fio-randread-4k.json", 27 "fio-randread-64k.json", 28 "fio-randread-8k.json", 29 "fio-randwrite-16k.json", 30 "fio-randwrite-32k.json", 31 "fio-randwrite-4k.json", 32 "fio-randwrite-64k.json", 33 "fio-randwrite-8k.json" 34 ) 35 36 data=c() 37 stats=c() 38 stats_names=c() 39 40 # For each set of results 41 for (currentdir in resultdirs) { 42 count=1 43 dirstats=c() 44 for (resultsfile in resultsfiles) { 45 fname=paste(inputdir, currentdir, resultsfile, sep="/") 46 if ( !file.exists(fname)) { 47 #warning(paste("Skipping non-existent file: ", fname)) 48 next 49 } 50 51 # Derive the name from the test result dirname 52 datasetname=basename(currentdir) 53 54 # Import the data 55 fdata=fromJSON(fname) 56 57 if (length(fdata$'kata-env') != 0 ) { 58 # We have kata-runtime data 59 dirstats=tibble("Run Ver"=as.character(fdata$'kata-env'$Runtime$Version$Semver)) 60 dirstats=cbind(dirstats, "Run SHA"=as.character(fdata$'kata-env'$Runtime$Version$Commit)) 61 62 pver=as.character(fdata$'kata-env'$Proxy$Version) 63 pver=sub("^[[:alpha:][:blank:]-]*", "", pver) 64 # uncomment if you want to drop the commit sha as well 65 #pver=sub("([[:digit:].]*).*", "\\1", pver) 66 dirstats=cbind(dirstats, "Proxy Ver"=pver) 67 68 # Trim the shim string 69 sver=as.character(fdata$'kata-env'$Shim$Version) 70 sver=sub("^[[:alpha:][:blank:]-]*", "", sver) 71 # uncomment if you want to drop the commit sha as well 72 #sver=sub("([[:digit:].]*).*", "\\1", sver) 73 dirstats=cbind(dirstats, "Shim Ver"=sver) 74 75 # Default QEMU ver string is far too long and noisy - trim. 76 hver=as.character(fdata$'kata-env'$Hypervisor$Version) 77 hver=sub("^[[:alpha:][:blank:]]*", "", hver) 78 hver=sub("([[:digit:].]*).*", "\\1", hver) 79 dirstats=cbind(dirstats, "Hyper Ver"=hver) 80 81 iver=as.character(fdata$'kata-env'$Image$Path) 82 iver=sub("^[[:alpha:]/-]*", "", iver) 83 dirstats=cbind(dirstats, "Image Ver"=iver) 84 85 kver=as.character(fdata$'kata-env'$Kernel$Path) 86 kver=sub("^[[:alpha:]/-]*", "", kver) 87 dirstats=cbind(dirstats, "Guest Krnl"=kver) 88 89 dirstats=cbind(dirstats, "Host arch"=as.character(fdata$'kata-env'$Host$Architecture)) 90 dirstats=cbind(dirstats, "Host Distro"=as.character(fdata$'kata-env'$Host$Distro$Name)) 91 dirstats=cbind(dirstats, "Host DistVer"=as.character(fdata$'kata-env'$Host$Distro$Version)) 92 dirstats=cbind(dirstats, "Host Model"=as.character(fdata$'kata-env'$Host$CPU$Model)) 93 dirstats=cbind(dirstats, "Host Krnl"=as.character(fdata$'kata-env'$Host$Kernel)) 94 dirstats=cbind(dirstats, "runtime"=as.character(fdata$test$runtime)) 95 96 break 97 } else { 98 if (length(fdata$'runc-env') != 0 ) { 99 dirstats=tibble("Run Ver"=as.character(fdata$'runc-env'$Version$Semver)) 100 dirstats=cbind(dirstats, "Run SHA"=as.character(fdata$'runc-env'$Version$Commit)) 101 dirstats=cbind(dirstats, "runtime"=as.character(fdata$test$runtime)) 102 } else { 103 dirstats=tibble("runtime"="Unknown") 104 } 105 break 106 } 107 } 108 109 if ( length(dirstats) == 0 ) { 110 warning(paste("No valid data found for directory ", currentdir)) 111 } 112 113 # use plyr rbind.fill so we can combine disparate version info frames 114 stats=rbind.fill(stats, dirstats) 115 stats_names=rbind(stats_names, datasetname) 116 } 117 118 rownames(stats) = stats_names 119 120 # Rotate the tibble so we get data dirs as the columns 121 spun_stats = as_tibble(cbind(What=names(stats), t(stats))) 122 123 # Build us a text table of numerical results 124 stats_plot = suppressWarnings(ggtexttable(data.frame(spun_stats, check.names=FALSE), 125 theme=ttheme(base_size=6), 126 rows=NULL 127 )) 128 129 # It may seem odd doing a grid of 1x1, but it should ensure we get a uniform format and 130 # layout to match the other charts and tables in the report. 131 master_plot = grid.arrange( 132 stats_plot, 133 nrow=1, 134 ncol=1 ) 135