1PMPARSEUNITSSTR(3) Library Functions Manual PMPARSEUNITSSTR(3)
2
3
4
6 pmParseUnitsStr - parse time point specification
7
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
17 pmParseUnitsStr is designed to encapsulate the interpretation of a
18 unit/scale specification in command line switches for use by the PCP
19 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. Briefly, the format allows /-separated divisor and dividend,
24 each listing space-separated dimensions/scales along the space, time,
25 and count axes. There are also a few extra possibilities:
26
27 First, multiple equivalent sets of keywords are accepted for the time &
28 space dimensions, insensitive to case. For example, "microseconds",
29 "microsecond", "microsec", "us" are considered synonymous, as are
30 "kilobytes", "KB", "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
41 The out and outMult values must both be allocated before calling pm‐
42 ParseUnitsStr. If the conversion is successful, pmParseUnitsStr re‐
43 turns 0, and fills in out and outMult with the unit/scales defined by
44 the input parameter. If the argument strings could not be parsed, it
45 returns a negative status code.
46
47
49 ┌──────────────────────────────────┬────────────────┬─────────┐
50 │ string │ out │ outMult │
51 ├──────────────────────────────────┼────────────────┼─────────┤
52 │2 count │ {0,1,0,0,0,0} │ 0.5 │
53 │count / 7.5 nanosecond │ {0,1,-1,0,0,0} │ 7.5 │
54 │10 kilobytes / 2.5e2 count x 10^3 │ {1,-1,0,1,3,0} │ 25 │
55 │millisecond / second^2 │ {0,0,-1,0,0,3} │ 1000 │
56 │mb/s │ {1,0,-1,2,0,3} │ 1 │
57 └──────────────────────────────────┴────────────────┴─────────┘
58
60 A zero status indicates success. A negative status indicates an error,
61 in which case the errMsg pointer will receive a textual error message,
62 which the caller should later free().
63
64
66 PMAPI(3), pmUnitsStr(3), pmConvScale(3), and pmLookupDesc(3).
67
68
69
70Performance Co-Pilot PCP PMPARSEUNITSSTR(3)