[ProgClub programming] numformat.php

John Elliot V | ProgClub jj5 at progclub.org
Sun Jun 2 12:56:13 AEST 2019


So I was trying to read some ZFS debugging info from:

 /proc/spl/kstat/zfs/arcstats

which looked something like this:

 13 1 0x01 96 4608 22091036583 580294752449707
 name                            type data
 hits                            4    2244288547
 misses                          4    72988333
 demand_data_hits                4    35769925
 demand_data_misses              4    3439818
 demand_metadata_hits            4    2188909634
 demand_metadata_misses          4    59434568

and I was having trouble gauging the order of magnitude of the numbers
so I wrote numformat.php:

 https://svn.jj5.net/jjrepo/jj5-bin/branches/0.2/bin/numformat.php

which formats numerical content like this:

 root at orac:/home/jj5# numformat.php < /proc/spl/kstat/zfs/arcstats
 13 1 0x01 96 4,608 22,091,036,583 580,436,679,049,214
 name                            type data
 hits                            4    2,244,304,800
 misses                          4    72,989,311
 demand_data_hits                4    35,770,479
 demand_data_misses              4    3,439,818
 demand_metadata_hits            4    2,188,925,033
 demand_metadata_misses          4    59,434,568

It would be nice if I could right-align numbers too, but I'm not that
clever... :)

May the Force be with you,
John Elliot V
-- 
|_|O|_| ProgClub
|_|_|O| Because every programmer needs a good club!
|O|O|O| https://www.progclub.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jj5.vcf
Type: text/x-vcard
Size: 231 bytes
Desc: not available
URL: <http://www.progclub.org/pipermail/programming/attachments/20190602/f8e453ac/attachment.vcf>


More information about the programming mailing list