-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
time
could be improved
#154
Comments
Milliseconds are definitely the way to go, when possible. There are also potential issues with On non-XSI systems,
Or
I'm not sure how you get from
It's unclear how something like
This looks easy enough to do, and i definitely like this idea, but it needs a bit more thought with respect to exception handling. Keep in mind that |
After a little time spent hacking up a version of this (see jpco/es-shell@bugfixes...jpco:es-shell:timier -- please excuse my horrible timeval math), I think you're basically right on all counts.
Yup, that's exactly what I did. Excerpted from my hacky version's initial.es:
Formatting, as you point out, is a challenge here; pattern extraction and matching can be used to round from
There's some design work to be done with that, yeah. Some thoughts off the top of my head:
Do you have any more detail on this? Is it just a matter of compounding errors while doing math (which I think would all get shaved off anyway converting from us or ns to ms), or is there some risk of the system double-counting or failing to count parent and child resources in some way? |
That should be easy enough to do since it's only the implementation of
This is why, after some reflection, i'm not in favor of
I think your exception-wrapping variation in #65 is suitable in the context of
Requiring a catcher to avoid interrupting
I definitely favor this idea.
The invocation order of the various timing commands could have an effect upon the result of |
Alright, I think it's reasonable to toss out the "returned timing data" idea. There are two things we'd lose (or would need to get another way if we didn't want to lose them):
but I don't feel terribly strongly about either of those, so it's probably fine to leave them. The only concrete use case I can imagine for the second one would be a bash-like That does still leave open the question of how we'd want to format the output. My first instinct would be to leave formatting as it currently is, just with more significant digits.
Ugh, what a mess! This is what I get trying to mess around with a standard for which I don't actually have the text. You know, bash (the only shell with a Because I can't help myself, I kind of want to have the printed precision depend on which function is used. Awkward and misleading to have a time like
Aha, yes, you're right the ordering matters. But do you mean |
Yes, i think milliseconds is precise enough for timing things.
You can use the Single Unix Specification starting with version 3.
Unfortunately, i don't know of any links to the original 2001 edition without the two TCs that make up POSIX.1-2004 (IEEE 1003.1-2001/Cor 2-2004), but i would expect most operating systems from 20 years ago to have been patched at some point, including changes to align with the updated standard, or upgraded to a newer release that supports it or even POSIX.1-2008. Anything without notation, like sysconf(), or with a
I find it reasonable as well, especially since
I believe the real-time duration should include |
For the record, I don't like either of these (they remind me too much of the constructs from other shells that drove me to es in the first place!)
I find this counterintuitive (my thinking is that if I wanted to time the timing machinery, I could just use something like |
Completely understandable.
Historically, the real time has always been greater than the user and system times, but your idea seems to be that the real time is the amount of time spent executing the task itself, which is reasonable and is likely to lead to the same outcome anyway. |
Some brainstorming about ways es'
time
builtin could be improved:More precise -- 0.1s is way too large a time quantum to be useful on modern machines, and 1s (for the real-time measurement) is absurd. I find myself running
bash -c 'time es -c ''blah'''
just to get meaningful timing output, which seems wrong. Milliseconds is probably most appropriate for a shell.Custom formatting -- It could be nice for
$&time
to simply return a list of(real user system)
, and havetime
decide how to format it. We could also have%time
in the middle to get a "three-layer" setup likevar
orwhatis
.time
could be changed to change how times are printed, and%time
could be changed to change how times are collected. Then, with a hookabletime
, you could keep the current whole-seconds and tenth-of-seconds printed formatting despite a more precise$&time
if you wanted to maintain the current behavior :)Forkless -- Speaking of changing how times are collected, it seems to me that with both
getrusage()
andtimes()
, we don't actually need to fork a new process to get a measure of the running time of a block. This is very interesting; whole scripts could be broken up into chunks wrapped intime
calls to find slow sections, without changing the functionality of the script at all. This would also, for example, allow the example of hookingtime
into%pipe
in the old es paper to be extended to other control flow constructs. Heck, you could hooktime
into%dispatch
,%seq
, orforever
without breaking anything! With a hookabletime
and%time
as described above, you could also wrap the timed command in afork {}
if you wanted to maintain the current behavior :)The text was updated successfully, but these errors were encountered: