What is difference between sys.time and Rprofiler in R



I am studying about method to optimize the code in R and while studying I came across two function
I want to know how this two are different from each other and where to use them


Sys.time just returns the current time and when you want to find the time taken by a process you may subtract the time after the process was completed from the time before.

On the other hand, Rprof() keeps track of the function call stack at regularly sampled intervals and tabulates how much time is spend in each function, default time being 0.02 seconds.

Hope this helps!