From james.f.hester at gmail.com  Thu Dec 21 18:45:47 2017
From: james.f.hester at gmail.com (Jim Hester)
Date: Thu, 21 Dec 2017 12:45:47 -0500
Subject: [Rd] Wish List: base::source() + Add Execution Time Argument
In-Reply-To: <CAF8bMca=5KcNt=2=ybsr+fP3L447xjCq2H2okKHU-zoibc2xFQ@mail.gmail.com>
References: <CANNd7=mvnfnuYHDfxog-bSLkKnG_AiMcmTj7p7GOj_hh_D5VYw@mail.gmail.com>
 <CAF8bMca=5KcNt=2=ybsr+fP3L447xjCq2H2okKHU-zoibc2xFQ@mail.gmail.com>
Message-ID: <CAD6tx95qxS3+xc3M_j-yVLdOt5pQP-uK9JqVhU1iZYBg66Se3A@mail.gmail.com>

R does provide the addTaskCallback / taskCallbackManager to run a
callback function after every top level command. However there is not
an equivalent interface that would be run _before_ each command, which
would make it possible to time of top level calls and provide other
execution measurements.

On Thu, Dec 21, 2017 at 11:31 AM, William Dunlap via R-devel
<r-devel at r-project.org> wrote:
> Is source() the right place for this?  It may be, but we've had customers
> who would like
> this sort of thing done for commands entered by hand.  And there are those
> who want
> a description of any "non-triivial" objects created in .GlobalEnv by each
> expression, ...
> Do they need a way to wrap each expression evaluated in envir=.GlobalEnv
> with a
> function of their choice, one that would print times, datasets created,
> etc.?
>
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
>
> On Thu, Dec 21, 2017 at 3:46 AM, Juan Telleria <jtelleriar at gmail.com> wrote:
>
>> Dear R Developers,
>>
>> Adding to source() base function a Timer which indicates the execution time
>> of the source code would be a very well welcome feature, and in my opinion
>> not difficult to implement as an additional funtion argument.
>>
>> The source(timing = TRUE) function shall execute internally the following
>> code for each statement:
>>
>> old <- Sys.time() # get start time at the beginning of source()
>> # source code
>> # print elapsed time
>> new <- Sys.time() - old # calculate difference
>> print(new) # print in nice format
>>
>> Thank you.
>>
>> Kind regards,
>>
>> Juan Telleria
>>
>>         [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Wish List: base::source() + Add Execution Time Argument
Jim Hester