mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 04:45:04 +02:00
small, backwards compatible enhancements to std (#14763)
# Description Small, backwards compatible enhancements to the standard library. # User-Facing Changes - changed `iter find`, `iter find-index`: Only consume the input stream up to the first match. - added `log set-level`: a small convenience command for setting the log level - added `$null_device`: `null-device` as a const variable, would allow conditional sourcing if #13872 is fixed # Tests + Formatting - 🟢 toolkit fmt - 🟢 toolkit clippy - 🟢 toolkit test - 🟢 toolkit test stdlib # After Submitting N/A
This commit is contained in:
@ -41,21 +41,21 @@ export def main [
|
||||
--verbose (-v) # be more verbose (namely prints the progress)
|
||||
--pretty # shows the results in human-readable format: "<mean> +/- <stddev>"
|
||||
] {
|
||||
let times = (
|
||||
let times: list<duration> = (
|
||||
seq 1 $rounds | each {|i|
|
||||
if $verbose { print -n $"($i) / ($rounds)\r" }
|
||||
timeit { do $code } | into int | into float
|
||||
timeit { do $code }
|
||||
}
|
||||
)
|
||||
|
||||
if $verbose { print $"($rounds) / ($rounds)" }
|
||||
|
||||
let report = {
|
||||
mean: ($times | math avg | from ns)
|
||||
min: ($times | math min | from ns)
|
||||
max: ($times | math max | from ns)
|
||||
std: ($times | math stddev | from ns)
|
||||
times: ($times | each { from ns })
|
||||
mean: ($times | math avg)
|
||||
min: ($times | math min)
|
||||
max: ($times | math max)
|
||||
std: ($times | into int | math stddev | into int | into duration)
|
||||
times: ($times)
|
||||
}
|
||||
|
||||
if $pretty {
|
||||
@ -64,8 +64,3 @@ export def main [
|
||||
$report
|
||||
}
|
||||
}
|
||||
|
||||
# convert an integer amount of nanoseconds to a real duration
|
||||
def "from ns" [] {
|
||||
[$in "ns"] | str join | into duration
|
||||
}
|
Reference in New Issue
Block a user