Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

microbenchmark as data frame or matrix

is there any way to transform output of function microbenchmark::microbenchmark into the data frame or matrix?

For example

v <- rnorm(100)
m <- microbenchmark(mean(v), sum(v))

The output

Unit: nanoseconds
   expr  min     lq    mean median   uq   max neval
mean(v) 6568 6979.5 9348.19   7390 7390 54600   100
 sum(v)    0    1.0  353.57    411  411  8211   100

I want to use this statistics later so I thought about saving the result as data frame. But as.data.frame(m) doesn't work.

Any help appreciated.

like image 797
jjankowiak Avatar asked Mar 28 '15 23:03

jjankowiak


2 Answers

This will return a data.frame:

summary(m)
like image 162
G. Grothendieck Avatar answered Nov 03 '22 13:11

G. Grothendieck


You can save m as a dataframe with the following code:

m <- summary(microbenchmark(mean(v), sum(v))) #note the addition of summary
m.df<- data.frame(m)
like image 32
User7598 Avatar answered Nov 03 '22 15:11

User7598