Skip to content
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

yash: no such command `time' #56

Open
chimps-ahoy opened this issue Aug 12, 2024 · 3 comments
Open

yash: no such command `time' #56

chimps-ahoy opened this issue Aug 12, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@chimps-ahoy
Copy link

Is your feature request related to a problem? Please describe.
yash does not include the time command as a built-in

Describe the solution you'd like
I suggest this utility should be provided as a shell built-in, as this is the case with other shells, and some Linux distributions do not come with the utility installed (although it can be easily installed through a package manager)

Describe alternatives you've considered
This can simply be rejected if you want, and we can leave it up to the user to have time as its own binary.

Additional context
I think it would make sense for this utility to be built-in, as it would probably be more accurate (?).
Also, as seen in the title, there is a typo in the error message with a mismatch of ` and '

@chimps-ahoy chimps-ahoy added the enhancement New feature or request label Aug 12, 2024
@magicant
Copy link
Owner

Thanks for the suggestion, but I recommend using one of the external time implementations, as they usually provide more information than the built-in shell versions.

The only situation where a built-in time implementation would be useful would be if you wanted to measure the time of an entire subshell, as in time (echo foo; echo bar; echo baz), which cannot be achieved directly by an external implementation. For now, you can work around this by doing time sh -c 'echo foo; echo bar; echo baz'.

@Veraellyunjie
Copy link

I recommend using one of the external time implementations, as they usually provide more information than the built-in shell versions

Could you please recommend good external time implementations?
Perhaps, the question deserves a wiki/FAQ entry?


/usr/bin/time on my machine reports double-digit milliseconds and above, but not single-digit milliseconds and below:

sh> /usr/bin/time sh -c 'echo hello world'
hello world
        0.00 real         0.00 user         0.00 sys

similar issue with sh time built-in:

sh> time sh -c 'echo hello world'
hello world
    0m00.00s real     0m00.00s user     0m00.00s system

As if it took no time!
Compare it to glorious fish shell time built-in:

fish> time sh -c 'echo hello world'
hello world

________________________________________________________
Executed in    3.83 millis    fish           external
   usr time   10.00 millis   10.00 millis    0.00 micros
   sys time    0.00 millis    0.00 millis    0.00 micros

it can measure other fish shell built-ins as well:

fish> time echo hello world
hello world

________________________________________________________
Executed in   21.00 micros    fish           external
   usr time    0.00 micros    0.00 micros    0.00 micros
   sys time    0.00 micros    0.00 micros    0.00 micros


please notice it goes as low as microseconds

@magicant
Copy link
Owner

GNU time seems to support showing all the fields returned from getrusage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants