Documentation ¶
Overview ¶
Package lib includes several library routines for ps-top
Index ¶
- Constants
- Variables
- func Divide(a uint64, b uint64) float64
- func FormatAmount(amount uint64) string
- func FormatCounter(counter int, width int) string
- func FormatPct(pct float64) string
- func FormatTime(picoseconds uint64) string
- func QualifiedTableName(schema, table string) string
- func SignedDivide(a int64, b int64) float64
- func SignedFormatAmount(amount int64) string
Constants ¶
const (
// Copyright provide a copyright notice
Copyright = "Copyright (C) 2014-2022 Simon J Mudd <sjmudd@pobox.com>"
)
Variables ¶
var ProgName string
ProgName returns the program's name based on a cleaned version of os.Args[0]. Given this might be used a lot ensure we generate the value once and then cache the result.
Functions ¶
func FormatAmount ¶
FormatAmount converts numbers to k = 1024 , M = 1024 x 1024, G = 1024 x 1024 x 1024, P = 1024x1024x1024x1024 and then formats them. For values = 0 return an empty string. For values < 1000 show 6,2 decimal places. For values >= 1000 show 6,1 decimal place.
func FormatCounter ¶ added in v0.1.5
FormatCounter formats a counter like an Amount but is tighter in space
func FormatPct ¶
FormatPct formats a floating point number as a percentage including the trailing % sign. Print the value as a %5.1f with a % suffix if there's a value. If the value is 0 print as 6 spaces. if the value is > 999.9 then show +++.+% to indicate an overflow.
func FormatTime ¶
FormatTime is based on sys.format_time. It formats to 10 characters including space and suffix. All values have 2 decimal places. Zero is returned as an empty string.
func QualifiedTableName ¶ added in v1.0.13
QualifiedTableName returns the anonymised qualified table name from the columns as '<schema>.<table>'
func SignedDivide ¶ added in v0.7.15
SignedDivide divides a by b except if b is 0 in which case we return 0.
func SignedFormatAmount ¶ added in v0.7.6
SignedFormatAmount formats a signed integer as per FormatAmount()
Types ¶
This section is empty.