1PMPARSEUNITSSTR(3)         Library Functions Manual         PMPARSEUNITSSTR(3)
2
3
4

NAME

6       pmParseUnitsStr - parse units specification
7

C SYNOPSIS

9       #include <pcp/pmapi.h>
10
11       int pmParseUnitsStr(const char *string, struct pmUnits *out,
12               double *outMult, char **errMsg);
13
14       cc ... -lpcp
15

DESCRIPTION

17       pmParseUnitsStr is designed to  encapsulate  the  interpretation  of  a
18       units  (dimension and scale) specification in command line switches for
19       use by the PCP client tools.
20
21       This function expects to be called with the unit/scale specification as
22       string.   This  specification  takes  the general form produced by pmU‐
23       nitsStr(3).  Briefly, the format allows /-separated divisor  and  divi‐
24       dend,  each  listing space-separated dimensions/scales along the space,
25       time, and count axes.  There are also a few extra possibilities:
26
27       First, multiple equivalent sets of keywords are accepted for  the  time
28       and  space  dimensions,  insensitive  to case.  For example, "microsec‐
29       onds", "microsecond", "microsec", "us" are  considered  synonymous,  as
30       are "kilobytes", "KB", "KiB", "kiloByte", and so on.
31
32       Second,  units may be offered in any order, e.g., ms kb count x 10^3 or
33       count x 10^3 kb ms.  They may not be repeated within the denominator or
34       within  the numerator.  Each scale/unit keyword may be immediately fol‐
35       lowed by positive or negative exponents, e.g., ^-4.
36
37       Third, numerical scaling factors may be supplied.  These  are  factored
38       together with implicit scale conversions into the final outMult result.
39
40       The  out  and  outMult values must both be allocated before calling pm‐
41       ParseUnitsStr(3).  If the conversion is successful, pmParseUnitsStr re‐
42       turns  0,  and fills in out and outMult with the unit/scales defined by
43       the input parameter.  If the argument strings could not be  parsed,  it
44       returns a negative status code.
45

EXAMPLES

47           ┌──────────────────────────────────┬────────────────┬─────────┐
48           │             string               │      out       │ outMult │
49           ├──────────────────────────────────┼────────────────┼─────────┤
50           │2 count                           │ {0,1,0,0,0,0}  │ 0.5     │
51           │count / 7.5 nanosecond            │ {0,1,-1,0,0,0} │ 7.5     │
52           │10 kilobytes / 2.5e2 count x 10^3 │ {1,-1,0,1,3,0} │ 25      │
53           │millisecond / second^2            │ {0,0,-1,0,0,3} │ 1000    │
54           │mib/s                             │ {1,0,-1,2,0,3} │ 1       │
55           └──────────────────────────────────┴────────────────┴─────────┘

BUGS

57       For  backward  compatibility,  this interface interprets several tradi‐
58       tional computer science interpretations of space units  incorrectly  by
59       the International System of Units (SI) standard.
60
61       The  accepted unit string - in either singular or plural form - and the
62       pmParseUnitsStr interpretation for each are: megabyte(mebibyte),  giga‐
63       byte(gibibyte),     terabyte(tebibyte),     petabyte(pebibyte),     ex‐
64       abyte(exbibyte), zettabyte(zebibyte) and yottabyte(yobibyte).
65

RETURN VALUE

67       A zero status indicates success.  A negative status indicates an error,
68       in  which case the errMsg pointer will contain a textual error message,
69       which the caller should later free(3).
70

SEE ALSO

72       PMAPI(3), pmUnitsStr(3), pmConvScale(3), and pmLookupDesc(3).
73
74
75
76Performance Co-Pilot                  PCP                   PMPARSEUNITSSTR(3)
Impressum