|
NAME | C SYNOPSIS | DESCRIPTION | EXAMPLES | BUGS | RETURN VALUE | SEE ALSO | COLOPHON |
|
|
|
PMPARSEUNITSSTR(3) Library Functions Manual PMPARSEUNITSSTR(3)
pmParseUnitsStr - parse units specification
#include <pcp/pmapi.h>
int pmParseUnitsStr(const char *string, struct pmUnits *out,
double *outMult, char **errMsg);
cc ... -lpcp
pmParseUnitsStr is designed to encapsulate the interpretation of a
units (dimension and scale) specification in command line switches
for use by the PCP client tools.
This function expects to be called with the unit/scale specificaβ
tion as string. This specification takes the general form proβ
duced by pmUnitsStr(3). Briefly, the format allows /-separated
divisor and dividend, each listing space-separated dimenβ
sions/scales along the space, time, and count axes. There are alβ
so a few extra possibilities:
First, multiple equivalent sets of keywords are accepted for the
time and space dimensions, insensitive to case. For example, "miβ
croseconds", "microsecond", "microsec", "us" are considered synβ
onymous, as are "kilobytes", "KB", "KiB", "kiloByte", and so on.
Second, units may be offered in any order, e.g., ms kb count x
10^3 or count x 10^3 kb ms. They may not be repeated within the
denominator or within the numerator. Each scale/unit keyword may
be immediately followed by positive or negative exponents, e.g.,
^-4.
Third, numerical scaling factors may be supplied. These are facβ
tored together with implicit scale conversions into the final outβ
Mult result.
The out and outMult values must both be allocated before calling
pmParseUnitsStr(3). If the conversion is successful, pmParseUβ
nitsStr returns 0, and fills in out and outMult with the
unit/scales defined by the input parameter. If the argument
strings could not be parsed, it returns a negative status code.
βββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββ¬ββββββββββ
β string β out β outMult β
βββββββββββββββββββββββββββββββββββββΌβββββββββββββββββΌββββββββββ€
β 2 count β {0,1,0,0,0,0} β 0.5 β
β count / 7.5 nanosecond β {0,1,-1,0,0,0} β 7.5 β
β 10 kilobytes / 2.5e2 count x 10^3 β {1,-1,0,1,3,0} β 25 β
β millisecond / second^2 β {0,0,-1,0,0,3} β 1000 β
β mib/s β {1,0,-1,2,0,3} β 1 β
βββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββ΄ββββββββββ
For backward compatibility, this interface interprets several traβ
ditional computer science interpretations of space units incorβ
rectly according to the International System of Units (SI) stanβ
dard.
The accepted unit string - in either singular or plural form - and
the pmParseUnitsStr interpretation for each are: megabyte (is reβ
ally mebibyte), gigabyte (is really gibibyte), terabyte (is really
tebibyte), petabyte (is really pebibyte), exabyte (is really
exbibyte), zettabyte (is really zebibyte) and yottabyte (is really
yobibyte).
A zero status indicates success. A negative status indicates an
error, in which case the errMsg pointer will contain a textual erβ
ror message, which the caller should later free(3).
PMAPI(3), pmUnitsStr(3), pmConvScale(3), and pmLookupDesc(3).
This page is part of the PCP (Performance Co-Pilot) project. Inβ
formation about the project can be found at β¨http://www.pcp.io/β©.
If you have a bug report for this manual page, send it to
pcp@groups.io. This page was obtained from the project's upstream
Git repository β¨https://github.com/performancecopilot/pcp.gitβ© on
2026-05-24. (At that time, the date of the most recent commit
that was found in the repository was 2026-05-24.) If you discover
any rendering problems in this HTML version of the page, or you
believe there is a better or more up-to-date source for the page,
or you have corrections or improvements to the information in this
COLOPHON (which is not part of the original manual page), send a
mail to man-pages@man7.org
Performance Co-Pilot PCP PMPARSEUNITSSTR(3)
Pages that refer to this page: pcp2elasticsearch(1), pcp2graphite(1), pcp2influxdb(1), pcp2json(1), pcp2openmetrics(1), pcp2opentelemetry(1), pcp2spark(1), pcp2template(1), pcp2xlsx(1), pcp2xml(1), pcp2zabbix(1), pmdaopenmetrics(1), pmdaopentelemetry(1), pmrep(1), pmfetchgroup(3), pmparseunitsstr(3), pmregisterderived(3)