From 872a9acb280576187f400f9db3b8c9d14079b613 Mon Sep 17 00:00:00 2001 From: Thomas Roehl Date: Fri, 11 Mar 2022 20:10:18 +0100 Subject: [PATCH] Update README --- internal/ccUnits/README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/internal/ccUnits/README.md b/internal/ccUnits/README.md index ce6061c..eea0dee 100644 --- a/internal/ccUnits/README.md +++ b/internal/ccUnits/README.md @@ -72,14 +72,16 @@ Special parsing rules for the following measures: iff `prefix==Milli`, use `pref - `Cycles` - `Requests` -This means the prefixes `Micro` (like `ubytes`) and `Nano` like (`nflops/sec`) are not allowed and return an invalid unit. +This means the prefixes `Micro` (like `ubytes`) and `Nano` like (`nflops/sec`) are not allowed and return an invalid unit. But you can specify `mflops` and `mb`. +Prefixes for `%` or `percent` are ignored. ## Supported prefixes ```go const ( Base Prefix = iota + Exa = 1e18 Peta = 1e15 Tera = 1e12 Giga = 1e9 @@ -110,8 +112,8 @@ const ( Rotation Hertz Time - Power - Energy + Watt + Joule Cycles Requests Packets @@ -141,4 +143,10 @@ If there are special conversation rules between measures and you want to convert The two parsers for prefix and measure are called under the hood by `NewUnit()` and there might some special rules apply. Like in the above section about 'special unit detection', special rules for your new measure might be required. Currently there are two special cases: - Measures that are non-dividable like Flops, Bytes, Events, ... cannot use `Milli`, `Micro` and `Nano`. The prefix `m` is forced to `M` for these measures -- If the prefix is `p`/`P` (`Peta`) or `e`/`E` (`Exa`) and the measure is not detectable, it retries detection with the prefix. So first round it tries for example (prefix `p`, measure `ackets`) which fails, to it retries with (measure `packets` and no prefix). \ No newline at end of file +- If the prefix is `p`/`P` (`Peta`) or `e`/`E` (`Exa`) and the measure is not detectable, it retries detection with the prefix. So first round it tries, for example, prefix `p` and measure `ackets` which fails, so it retries the detection with measure `packets` and `` prefix (resolves to `Base` prefix). + +## Limitations + +The `ccUnits` package is a simple implemtation of a unit system and comes with some limitations: + +- The unit denominator (like `s` in `Mbyte/s`) can only have the `Base` prefix, you cannot specify `Byte/ms` for "Bytes per milli second".