mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
Update some benchmarks. Re-port the gradient benchmark (#558)
This commit is contained in:
parent
832f34fa06
commit
4a1eba5823
3 changed files with 96 additions and 53 deletions
|
@ -1,41 +1,37 @@
|
|||
# this script will print a blue gradient on the screen
|
||||
# height = 40
|
||||
# width = 160
|
||||
# stamp = "py"
|
||||
|
||||
# for line in range(0, height):
|
||||
# row_data = ""
|
||||
|
||||
# for col in range(0, width):
|
||||
# fgcolor = 2 + 2 * col
|
||||
# if fgcolor > 200 and fgcolor < 210:
|
||||
# row_data = row_data + color(stamp, bg='rgb(0, 0, %d)' % fgcolor)
|
||||
# else:
|
||||
# fg = fgcolor % 256
|
||||
# row_data = row_data + color(' ', bg='rgb(0, 0, %d)' % fg)
|
||||
|
||||
# print(row_data)
|
||||
|
||||
const height = 40
|
||||
const width = 160
|
||||
const stamp = "Nu"
|
||||
|
||||
for line in 0..$height {
|
||||
mut row_data = ""
|
||||
|
||||
for col in 0..$width {
|
||||
let fgcolor = 2 + 2 * $col
|
||||
|
||||
# We can get the terminal width and height now with term size
|
||||
# but we like to use the script as a benchmark, so let's keep
|
||||
# it a constant size for now
|
||||
let height = 40 # really need to get the terminal height here
|
||||
let width = 160 # really need to get the terminal width here
|
||||
let stamp = 'Nu'
|
||||
seq 0 $height | each { |row|
|
||||
let row_data = (seq 0 $width | each { |col|
|
||||
let fgcolor = (iter_inc 2 2 $col)
|
||||
if $fgcolor > 200 and $fgcolor < 210 {
|
||||
$"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
|
||||
$row_data += $"(ansi -e '48;2;0;0;')($fgcolor)m($stamp)(ansi -e '0m')"
|
||||
} else {
|
||||
$"(ansi -e '48;2;0;0;')($fgcolor)m(char sp)(ansi -e '0m')"
|
||||
let fg = $fgcolor mod 256
|
||||
$row_data += $"(ansi -e '48;2;0;0;')($fg)m (ansi -e '0m')"
|
||||
}
|
||||
} | str join)
|
||||
print -n $"($row_data)(char newline)"
|
||||
} | str join
|
||||
}
|
||||
|
||||
def iter_inc [incr mult iter] {
|
||||
$incr + $mult * $iter
|
||||
}
|
||||
|
||||
|
||||
# ╭────────────────────┬──────────────────────────────────────────────────────╮
|
||||
# │ version │ 0.1.0 │
|
||||
# │ branch │ main │
|
||||
# │ short_commit │ ec94ca46 │
|
||||
# │ commit_hash │ ec94ca46bb64f3aa95f1366d76d60da2ddc53782 │
|
||||
# │ commit_date │ 2022-01-24 19:45:20 +00:00 │
|
||||
# │ build_os │ windows-x86_64 │
|
||||
# │ rust_version │ rustc 1.58.1 (db9d1b20b 2022-01-20) │
|
||||
# │ rust_channel │ stable-x86_64-pc-windows-msvc │
|
||||
# │ cargo_version │ cargo 1.58.0 (f01b232bc 2022-01-19) │
|
||||
# │ pkg_version │ 0.1.0 │
|
||||
# │ build_time │ 2022-01-24 15:04:00 -06:00 │
|
||||
# │ build_rust_channel │ debug │
|
||||
# │ features │ dataframe, default, which, zip │
|
||||
# │ installed_plugins │ gstat, inc, nu-example-1, nu-example-2, nu-example-3 │
|
||||
# ╰────────────────────┴──────────────────────────────────────────────────────╯
|
||||
print $row_data
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue