Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    The usual way would be marginally more typing.

    Code:
    timer on 1
    ...your code...
    timer off 1
    timer list 1

    Comment


    • #17
      Yes, that's covered in the first post of the thread. My question was in the context of timeit.

      Comment


      • #18
        I believe the problem is the version statement. The error doesn't appear when the statement is changed to version 12, which is probably because additional functionality was added to rename group at that time. I'm not sure if changing the version breaks anything else, but if you want a temporary workaround that does the trick.
        Last edited by Ali Atia; 09 Jun 2021, 14:52.

        Comment


        • #19
          Does the trick. Thanks, Ali.

          Comment


          • #20
            Ali correctly diagnoses the problem; I suggest a different solution, though. Do not tinker with timeit.ado. Instead, change your programs to properly include the desired version, i.e., write

            Code:
            program define my_program
                        version 12 // <- add the version
                        sysuse "auto.dta"
                        ren weigh* weigh
            end
            Alternatively, type

            Code:
            timeit 1 : version 12 : my_program

            Jesse might want to add caller-version support (something that I tend to forget, too). The relevant changes might be as simple as

            Code:
            [...]
            nobreak {
                timer on `theTimer'
                capture noisily break version `=_caller()' : `theCommand'
                timer off `theTimer'
            }
            [...]

            Comment


            • #21
              daniel klein Yes!!!!

              Sorry, I have been looking for a way to respect the host version in a robust way for a long time now and this does that brilliantly.

              I've adapted the code, it's en route to SSC now (and attached)
              Attached Files

              Comment


              • #22
                Updated such that named timers progress independently from numbered ones. In the example below, the "regression" timer cumulates to 1500ms, despite being linked to different numbered timers in each call.

                Inspired by this post.

                Thanks to Kit Baum as usual for the ssc update.

                Code:
                . timeit 1 regression: sleep 1000
                . timeit 2 regression: sleep 500
                . return list scalars:
                   r(delta_regression) =  .509
                         r(regression) =  1.512
                           r(delta_t2) =  .509
                                 r(t2) =  .509
                           r(delta_t1) =  1.003
                                 r(t1) =  1.003
                Last edited by Jesse Wursten; 06 Oct 2022, 00:38.

                Comment

                Working...
                X