Spaceship-prompt: More specific exec_time

Created on 1 Mar 2018  Â·  3Comments  Â·  Source: denysdovhan/spaceship-prompt

Issue

Could we get a new option for exec_time that allows a more exact execution time output?

e.g. 2.34s instead of 2s

Would allow this to be more useful for basic benchmarking.

proposal wontfix

Most helpful comment

Hey @AlecRust, Good suggestion. But I'm afraid this would require major changes to exec_time section with chances of breaking section for many users.

Now let me explain why, spaceship_exec_time_precmd_hook considers time in seconds.

https://github.com/denysdovhan/spaceship-prompt/blob/3bde13162fc8060ef4c47994b0cc3d27e4ebf000/lib/hooks.zsh#L20

To support ms we would be required to pass time in milliseconds. Which unfortunately date don't have flag for milliseconds. We would be required to convert nanoseconds (date +%s%3N). But macOS doesn't support any more precision than seconds.

Even if we tackle these problems and implement this, I'm not in favor of displaying ms with every prompt. In addition to @maximbaz suggestion, We could add an option like SPACESHIP_EXEC_TIME_MS_SHOW which could be disabled by default.

All 3 comments

Since today it can show 1d 3h 24m 33s we could add 34 ms to it.

Not sure yet if I like this idea, but here it goes: since milliseconds matter only on tiny time intervals, maybe instead of adding another configuration for this, show ms only to those people who configured SPACESHIP_EXEC_TIME_ELAPSED=0?

Hey @AlecRust, Good suggestion. But I'm afraid this would require major changes to exec_time section with chances of breaking section for many users.

Now let me explain why, spaceship_exec_time_precmd_hook considers time in seconds.

https://github.com/denysdovhan/spaceship-prompt/blob/3bde13162fc8060ef4c47994b0cc3d27e4ebf000/lib/hooks.zsh#L20

To support ms we would be required to pass time in milliseconds. Which unfortunately date don't have flag for milliseconds. We would be required to convert nanoseconds (date +%s%3N). But macOS doesn't support any more precision than seconds.

Even if we tackle these problems and implement this, I'm not in favor of displaying ms with every prompt. In addition to @maximbaz suggestion, We could add an option like SPACESHIP_EXEC_TIME_MS_SHOW which could be disabled by default.

I don't like the idea of adding a new option. Moreover, I'd like to postpone adding new options until we have some test cases. More options → harder to test.

Right now exec_time work fine. Having ms is the matter of taste. I like this idea, but it takes too much to have it implemented on every supported platform. That isn't a critical feature. Our primary goals right now:

  • Cover as much as possible with tests
  • Make prompt faster with async rendering
Was this page helpful?
0 / 5 - 0 ratings

Related issues

gillesdemey picture gillesdemey  Â·  3Comments

salmanulfarzy picture salmanulfarzy  Â·  3Comments

doole picture doole  Â·  4Comments

vburojevic picture vburojevic  Â·  3Comments

Vvkmnn picture Vvkmnn  Â·  3Comments