added a code example to nushell post.

This commit is contained in:
Gabe Venberg 2024-03-06 18:28:07 -06:00
parent 2224ba8c20
commit c004fe1086

View file

@ -50,6 +50,36 @@ thoughts, and some criticisms along the way.
== Parsing non-nu tools
// show parsing initcall_debug logs, and how it then lets one do analysis on it
```
[ 0.518096] calling prandom_reseed+0x0/0x40 @ 1
[ 0.518119] initcall prandom_reseed+0x0/0x40 returned 0 after 12 usecs
[ 0.518127] calling clk_debug_init+0x0/0x140 @ 1
[ 0.531128] initcall clk_debug_init+0x0/0x140 returned 0 after 12659 usecs
[ 0.531145] calling imx_amp_power_init+0x0/0x13c @ 1
[ 0.531156] initcall imx_amp_power_init+0x0/0x13c returned 0 after 1 usecs
[ 0.531175] calling deferred_probe_initcall+0x0/0x3c @ 1
[ 0.532275] imx_thermal 2000000.aips-bus:tempmon: Automotive CPU temperature grade - max:125C critical:120C passive:115C
[ 0.533166] pcm1753 pcm1753: Setting maximum volume limit of 226
[ 0.535167] asoc-simple-card sound: PCM1753-HiFi <-> 2024000.esai mapping ok
[ 0.536199] initcall deferred_probe_initcall+0x0/0x3c returned 0 after 4880 usecs
[ 0.536217] calling pm_genpd_debug_init+0x0/0x70 @ 1
[ 0.536249] initcall pm_genpd_debug_init+0x0/0x70 returned 0 after 20 usecs
[ 0.536262] calling genpd_poweroff_unused+0x0/0x8c @ 1
[ 0.536284] initcall genpd_poweroff_unused+0x0/0x8c returned 0 after 11 usecs
[ 0.536296] calling gpio_keys_init+0x0/0x20 @ 1
```
{{<highlight nushell "linenos=false">}}
open $file |
lines |
find '] initcall ' |
parse -r '\[\s*(?<timestamp>\d+\.\d+)\] (?<message>.+) returned (?<return>\d+) after (?<delta>.+)' |
update timestamp {into float} |
update delta {str replace ' usecs' 'us'} |
update delta {into duration} |
update return {into int} |
move delta --after timestamp
{{</highlight>}}
== Defining custom commands