func calculate_rate(bigger, smaller, seconds float64) float64 {
	diff := calculate_diff(bigger, smaller)
	if seconds <= 0 {  
		return diff
	} else {
		return diff / seconds
	}
}
Calculate the rate of change between two values, given the time difference between them
package myqlib
import (
	"fmt"
	"sort"
	"strings"
	"unicode/utf8"
)
type UnitsDef map[float64]string
var (
	NumberUnits UnitsDef = UnitsDef{
		1:          ``,
		1000:       `k`,
		1000000:    `m`,
		1000000000: `g`,
	}
	MemoryUnits UnitsDef = UnitsDef{
		1:             `b`,
		1024:          `K`,
		1048576:       `M`,
		1073741824:    `G`,
		1099511627776: `T`,
	}
	SecondUnits UnitsDef = UnitsDef{
		1000:        `ks`,
		1:           `s`,
		0.001:       `ms`,
		0.000001:    `µs`,
		0.000000001: `ns`,
	}
	MicroSecondUnits UnitsDef = UnitsDef{
		1000000000: `ks`,
		1000000:    `s`,
		1000:       `ms`,
		1:          `µs`,
	}
	NanoSecondUnits UnitsDef = UnitsDef{
		1000000000: `s`,
		1000000:    `ms`,
		1000:       `µs`,
		1:          `ns`,
	}
	PercentUnits UnitsDef = UnitsDef{
		1: `%`,
	}
)
func collapse_number(value float64, width int64, precision int64, units UnitsDef) string {
	var factors []float64
	for k := range units {
		factors = append(factors, k)
	}
	sort.Float64s(factors)
	for _, factor := range factors {
		unit := units[factor]
		raw := value / factor
		str := fmt.Sprintf(fmt.Sprint(`%.`, precision, `f%s`), raw, unit)
		left := width - int64(utf8.RuneCountInString(str))
		if raw >= 0 && (width+precision)-int64(utf8.RuneCountInString(str)) >= 0 {
			if left < 0 {
				if precision > 0 {
					return collapse_number(value, width, precision-1, units)
				} else {
					return str
				}
			} else if left > 1 && factor != 1 {
				return fmt.Sprintf(fmt.Sprint(`%.`, left-1, `f%s`), raw, unit)
			} else {
				if factor != 1 && raw < 1 && left > 0 && fmt.Sprintf(`%.1f`, raw ) != `1.0` {
					return fmt.Sprintf(fmt.Sprint(`%0.`, precision+left, `f%s`), raw, unit)[1:]
				} else if factor != 1 && str == fmt.Sprintf("0%s", unit) {
					if left > 0 {
						return fmt.Sprintf(fmt.Sprint(`%.`, precision+1, `f%s`), raw, unit)[1:]
					}
					return strings.Repeat(`#`, int(width))
				} else {
					return str
				}
			}
		}
	}
	str := fmt.Sprintf(fmt.Sprint(`%.`, precision, `f`), value)
	if int64(len(str)) > width && precision > 0 {
		return collapse_number(value, width, precision-1, units)
	} else {
		return strings.Repeat(`#`, int(width))
	}
}
func calculate_diff(bigger, smaller float64) float64 {
	if bigger < smaller {
		return bigger
	} else {
		return bigger - smaller
	}
}