How to check the difference between plot generation time in base R?


One of the mostly used time measurement function in R is microbenchmark function of microbenchmark package. We can pass the function to create the plot inside microbenchmark function and this will result in the processing time for each of the plots then a comparison can be done for the difference.

Example1

Loading microbenchmark package:

> library(microbenchmark)

Finding the plot generation time:

> x1<-rpois(10,5)
> x2<-rpois(100,5)
> x3<-rpois(1000,5)
> X<-microbenchmark(plot(x1),plot(x2),plot(x3))
> X

Unit: milliseconds


   expr      min    lq       mean     median uq       max  neval
plot(x1) 12.7488 14.88815 15.65040 15.2515 15.90765 23.9348  100
plot(x2) 20.9810 21.67780 23.92976 22.2116 23.29665 137.2474 100
plot(x3) 93.6965 95.03440 96.67086 95.6717 97.12290 125.3670 100

Plots:

Example

> plot(x1)

Output:

Example

> plot(x2)

Output:

Example

> plot(x3)

Output:

Updated on: 06-Nov-2020

49 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements