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

Improve sleep resolution #12049

Merged
merged 1 commit into from Mar 2, 2024
Merged

Improve sleep resolution #12049

merged 1 commit into from Mar 2, 2024

Conversation

Dorumin
Copy link
Contributor

@Dorumin Dorumin commented Mar 2, 2024

Description

This improves the resolution of the sleep commands by simply not clamping to the default 100ms ctrl+c signal checking loop if the passed-in duration is shorter.

User-Facing Changes

You can use smaller values in sleep.

# Before
timeit { 0..100 | each { |row| print $row; sleep 10ms; } } # +10sec

# After
timeit { 0..100 | each { |row| print $row; sleep 10ms; } } # +1sec

It still depends on the internal behavior of thread::sleep and the OS timers. In windows it doesn't seem to go much lower than 15 or 10ms, or 0 if you asked for that.

After Submitting

Sleep didn't have anything documenting its minimum value, so this should be more in line with its standard procedure. It will still never sleep for less time than allocated.

Did you know sleep can take multiple durations, and it'll add them up? I didn't

@fdncred
Copy link
Collaborator

fdncred commented Mar 2, 2024

Seems reasonable. Thanks

@fdncred fdncred merged commit 669659f into nushell:main Mar 2, 2024
19 checks passed
@hustcer hustcer added this to the v0.91.0 milestone Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants