Giter Club home page Giter Club logo

Comments (3)

magicant avatar magicant commented on September 4, 2024 1

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'.

from yash.

Veraellyunjie avatar Veraellyunjie commented on September 4, 2024

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

from yash.

magicant avatar magicant commented on September 4, 2024

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

from yash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.