Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8938835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:43:22+00:00 2026-06-15T10:43:22+00:00

I have to do extensive data manipulation on a big data set (using data.table,

  • 0

I have to do extensive data manipulation on a big data set (using data.table, RStudio mostly). I would like to monitor run time for each of my step without explicitly call system.time() on each step.

Is there a package or an easy way to show run time by default on each step?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T10:43:23+00:00Added an answer on June 15, 2026 at 10:43 am

    It’s not exactly what you’re asking for, but I’ve written time_file (https://gist.github.com/4183595) which source()s an R file, and runs the code, then rewrites the file, inserting comments containing how long each top-level statement took to run.

    i.e. time_file() turns this:

    {
      load_all("~/documents/plyr/plyr")
      load_all("~/documents/plyr/dplyr")
      library(data.table)
      data("baseball", package = "plyr")
      vars <- list(n = quote(length(id)), m = quote(n + 1))
    }
    
    # Baseline case: use ddply
    a <- ddply(baseball, "id", summarise, n = length(id))
    
    # New summary method: ~20x faster
    b <- summarise_by(baseball, group("id"), vars)
    
    # But still not as fast as specialised count, which is basically id + tabulate
    # so maybe able to eke out a little more with a C loop ?
    count(baseball, "id")
    

    into this:

    {
      load_all("~/documents/plyr/plyr")
      load_all("~/documents/plyr/dplyr")
      library(data.table)
      data("baseball", package = "plyr")
      vars <- list(n = quote(length(id)), m = quote(n + 1))
    }
    
    # Baseline case: use ddply
    a <- ddply(baseball, "id", summarise, n = length(id))
    #:    user  system elapsed
    #:   0.451   0.003   0.453
    
    # New summary method: ~20x faster
    b <- summarise_by(baseball, group("id"), vars)
    #:    user  system elapsed
    #:   0.029   0.000   0.029
    
    # But still not as fast as specialised count, which is basically id + tabulate
    # so maybe able to eke out a little more with a C loop ?
    count(baseball, "id")
    #:    user  system elapsed
    #:   0.008   0.000   0.008
    

    It doesn’t time code inside a top-level { block, so you can choose not to time stuff you’re not interested in.

    I don’t think there’s anyway to automatically add timing as a top-level effect without somehow modifying the way that you run the code – i.e. using something like time_file instead of source.

    You might wonder the effect that timing every top-level operation has on the overall speed of your code. Well, that’s easy to answer with a microbenchmark 😉

    library(microbenchmark)
    microbenchmark(
      runif(1e4), 
      system.time(runif(1e4)),
      system.time(runif(1e4), gc = FALSE)
    )
    

    So timing adds relatively little overhead (20µs on my computer), but the default gc adds about 27 ms per call. So unless you have thousands of top-level calls, you’re unlikely to see much impact.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an extensive menu in which I would like to search for and
We have a data model that has some requirements. I would like to find
I have a relatively extensive sqlite database that I'd like to import into my
I have an Android Spinner view in my layout. I would like that spinner
I have quite an extensive PHP script that I have to run on my
I have written an extension method to help with collecting crash data during error
I have developed a python C-extension that receives data from python and compute some
I'm technically savvy but don't have extensive experience with servers/daemons (I'm a Windows guy,
I have a webforms page that makes quite extensive use of AJAX. There are
I have a simple unit test case (extensive question here ) on a configuration

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.