Microbenchmark as a data frame or matrix

Is there a way to convert the output of a function microbenchmark::microbenchmarkto a frame or data matrix?

for instance

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

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 these statistics later, so I thought about saving the result as a data frame. But as.data.frame(m)does not work.

Any help was appreciated.

+4
source share
2 answers

This will return data.frame:

summary(m)
+7
source

You can save mas a data framework with the following code:

m <- summary(microbenchmark(mean(v), sum(v))) #note the addition of summary
m.df<- data.frame(m)
+3
source

All Articles