[R] Memory usage bar plot
arun
smartpink111 at yahoo.com
Fri Aug 30 16:18:44 CEST 2013
HI,
You could also parse the data by:
input1<- input
library(stringr)
input2<-str_trim(gsub("[=+]","",input1))
dat1<-read.table(text=word(input2[!grepl("---",input2)& input2!="" & !grepl("RAM|MiB",input2)],8,15),sep="",header=FALSE,stringsAsFactors=FALSE)
lst1<-split(dat1,cumsum(dat1$V3=="uuidd"))
lst1
#$`1`
# V1 V2 V3
#1 107.5 KiB uuidd
#2 120.5 KiB klogd
#3 141.0 KiB hidd
#4 146.0 KiB acpid
#5 153.5 KiB hald-addon-storage
#6 159.0 KiB gpm
#7 162.5 KiB pam_timestamp_check
#
#$`2`
# V1 V2 V3
#8 107.5 KiB uuidd
#9 120.5 KiB klogd
#10 141.0 KiB hidd
#11 146.0 KiB acpid
#12 153.5 KiB hald-addon-storage
#13 159.0 KiB gpm
#14 162.5 KiB pam_timestamp_check
A.K.
----- Original Message -----
From: jim holtman <jholtman at gmail.com>
To: mohan.radhakrishnan at polarisft.com
Cc: R mailing list <r-help at r-project.org>
Sent: Friday, August 30, 2013 9:44 AM
Subject: Re: [R] Memory usage bar plot
Here is how to parse the data and put it into groups. Not sure what
the 'timing' of each group is since not time information was given.
Also not sure is there is an 'MiB' qualifier on the data, but you have
the matrix of data which is easy to do with as you want.
> input <- readLines(textConnection("
+ Private + Shared = RAM used Program
+
+ 96.0 KiB + 11.5 KiB = 107.5 KiB uuidd
+ 108.0 KiB + 12.5 KiB = 120.5 KiB klogd
+ 124.0 KiB + 17.0 KiB = 141.0 KiB hidd
+ 116.0 KiB + 30.0 KiB = 146.0 KiB acpid
+ 124.0 KiB + 29.5 KiB = 153.5 KiB hald-addon-storage
+ 144.0 KiB + 15.0 KiB = 159.0 KiB gpm
+ 136.0 KiB + 26.5 KiB = 162.5 KiB pam_timestamp_check
+ ---------------------------------------------------------
+ 453.9 MiB
+
+ =================================
+ Private + Shared = RAM used Program
+
+ 96.0 KiB + 11.5 KiB = 107.5 KiB uuidd
+ 108.0 KiB + 12.5 KiB = 120.5 KiB klogd
+ 124.0 KiB + 17.0 KiB = 141.0 KiB hidd
+ 116.0 KiB + 30.0 KiB = 146.0 KiB acpid
+ 124.0 KiB + 29.5 KiB = 153.5 KiB hald-addon-storage
+ 144.0 KiB + 15.0 KiB = 159.0 KiB gpm
+ 136.0 KiB + 26.5 KiB = 162.5 KiB pam_timestamp_check
+ ----------------------------------------------------------
+ 453.9 MiB
+ ================================="))
>
> # keep only the data
> input <- input[grepl('=', input)]
>
> # separate into groups
> grps <- split(input, cumsum(grepl("= RAM", input)))
>
> # parse the data (not sure if there is also 'MiB')
> parsed <- lapply(grps, function(.grp){
+ # parse ignoring first and last lines
+ .data <- sub(".*= ([^ ]+) ([^ ]+)\\s+(.*)", "\\1 \\2 \\3"
+ , .grp[2:(length(.grp) - 1L)]
+ )
+ # return matrix
+ do.call(rbind, strsplit(.data, ' '))
+ })
>
>
>
> parsed
$`1`
[,1] [,2] [,3]
[1,] "107.5" "KiB" "uuidd"
[2,] "120.5" "KiB" "klogd"
[3,] "141.0" "KiB" "hidd"
[4,] "146.0" "KiB" "acpid"
[5,] "153.5" "KiB" "hald-addon-storage"
[6,] "159.0" "KiB" "gpm"
[7,] "162.5" "KiB" "pam_timestamp_check"
$`2`
[,1] [,2] [,3]
[1,] "107.5" "KiB" "uuidd"
[2,] "120.5" "KiB" "klogd"
[3,] "141.0" "KiB" "hidd"
[4,] "146.0" "KiB" "acpid"
[5,] "153.5" "KiB" "hald-addon-storage"
[6,] "159.0" "KiB" "gpm"
[7,] "162.5" "KiB" "pam_timestamp_check"
>
Jim Holtman
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Fri, Aug 30, 2013 at 7:24 AM, <mohan.radhakrishnan at polarisft.com> wrote:
> Hi,
> I haven't tried the code yet. Is there a way to parse this data
> using R and create bar plots so that each program's 'RAM used' figures are
> grouped together.
> So 'uuidd' bars will be together. The data will have about 50 sets. So if
> there are 100 processes each will have about 50 bars.
>
> What is the recommended way to graph these big barplots ? I am looking for
> only 'RAM used' figures.
>
>
> Thanks,
> Mohan
>
>
> Private + Shared = RAM used Program
>
> 96.0 KiB + 11.5 KiB = 107.5 KiB uuidd
> 108.0 KiB + 12.5 KiB = 120.5 KiB klogd
> 124.0 KiB + 17.0 KiB = 141.0 KiB hidd
> 116.0 KiB + 30.0 KiB = 146.0 KiB acpid
> 124.0 KiB + 29.5 KiB = 153.5 KiB hald-addon-storage
> 144.0 KiB + 15.0 KiB = 159.0 KiB gpm
> 136.0 KiB + 26.5 KiB = 162.5 KiB pam_timestamp_check
> ---------------------------------------------------------
> 453.9 MiB
>
> =================================
> Private + Shared = RAM used Program
>
> 96.0 KiB + 11.5 KiB = 107.5 KiB uuidd
> 108.0 KiB + 12.5 KiB = 120.5 KiB klogd
> 124.0 KiB + 17.0 KiB = 141.0 KiB hidd
> 116.0 KiB + 30.0 KiB = 146.0 KiB acpid
> 124.0 KiB + 29.5 KiB = 153.5 KiB hald-addon-storage
> 144.0 KiB + 15.0 KiB = 159.0 KiB gpm
> 136.0 KiB + 26.5 KiB = 162.5 KiB pam_timestamp_check
> ----------------------------------------------------------
> 453.9 MiB
> =================================
>
>
> This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.
>
> Visit us at http://www.polarisFT.com
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list