Wish List: base::source() + Add Execution Time Argument

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Wish List: base::source() + Add Execution Time Argument

Juan Telleria
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]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Wish List: base::source() + Add Execution Time Argument

Iñaki Úcar
2017-12-21 12:46 GMT+01:00 Juan Telleria <[hidden email]>:

> 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

system.time(source(...)) does what you want.

Iñaki

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Wish List: base::source() + Add Execution Time Argument

Juan Telleria
But by statement in the source file, I mean, for knowing during the
execution how much time is taking, without having to wait till the end.

2017-12-21 13:06 GMT+01:00 Iñaki Úcar <[hidden email]>:

> 2017-12-21 12:46 GMT+01:00 Juan Telleria <[hidden email]>:
> > 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
>
> system.time(source(...)) does what you want.
>
> Iñaki
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Wish List: base::source() + Add Execution Time Argument

Iñaki Úcar
2017-12-21 15:05 GMT+01:00 Juan Telleria <[hidden email]>:
> But by statement in the source file, I mean, for knowing during the
> execution how much time is taking, without having to wait till the end.

What's the ultimate purpose? Are you looking for a profiler (there are
some of them on CRAN) or some kind of progress bar (something like the
'progress' package would be useful)?

Iñaki

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Wish List: base::source() + Add Execution Time Argument

Juan Telleria
I did not know "progress" package existed, thank you Iñaki.

However, something like that would be nice to have by default in source(),
just something to add to R's "wish list", so that everybody can benefit
from it without extra-packages, as most of us I suppose we will spend all
day simply doing Ctrl + Run :)

Thank you,
Juan

2017-12-21 15:20 GMT+01:00 Iñaki Úcar <[hidden email]>:

> 2017-12-21 15:05 GMT+01:00 Juan Telleria <[hidden email]>:
> > But by statement in the source file, I mean, for knowing during the
> > execution how much time is taking, without having to wait till the end.
>
> What's the ultimate purpose? Are you looking for a profiler (there are
> some of them on CRAN) or some kind of progress bar (something like the
> 'progress' package would be useful)?
>
> Iñaki
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Wish List: base::source() + Add Execution Time Argument

R devel mailing list
In reply to this post by Juan Telleria
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 <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Wish List: base::source() + Add Execution Time Argument

Jim Hester
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
<[hidden email]> 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 <[hidden email]> 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]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Wish List: base::source() + Add Execution Time Argument

Tomas Kalibera
There is a simple way to achieve something similar: one can add a time
stamp to each line of output, e.g. using "ts" command from "moreutils".

Tomas

On 12/21/2017 06:45 PM, Jim Hester wrote:

> 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
> <[hidden email]> 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 <[hidden email]> 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]]
>>>
>>> ______________________________________________
>>> [hidden email] mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>          [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> [hidden email] mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel