analyze: Add "timespan" command to dump time span in usec

This is useful for a couple of cases, I'm mostly interested in case #1:

1. Verifying "reasonable" values in a trivially scriptable way
2. Debugging unexpected time span parsing directly

Test Plan:

```
% build/systemd-analyze timespan 20
Original: 20
      μs: 20
   Human: 20us
% build/systemd-analyze timespan 20ms
Original: 20ms
      μs: 20000
   Human: 20ms
% build/systemd-analyze timespan 20z
Failed to parse time span '20z': Invalid argument
```
This commit is contained in:
Chris Down
2018-10-15 12:55:35 +01:00
committed by Lennart Poettering
parent f402ce827d
commit 3f1c1287a9
6 changed files with 46 additions and 2 deletions

View File

@@ -367,7 +367,8 @@ const char *special_glyph(SpecialGlyph code) {
[BLACK_CIRCLE] = "*",
[ARROW] = "->",
[MDASH] = "-",
[ELLIPSIS] = "..."
[ELLIPSIS] = "...",
[MU] = "u",
},
/* UTF-8 */
@@ -381,6 +382,7 @@ const char *special_glyph(SpecialGlyph code) {
[ARROW] = "\342\206\222", /* → */
[MDASH] = "\342\200\223", /* */
[ELLIPSIS] = "\342\200\246", /* … */
[MU] = "\316\274", /* μ */
},
};

View File

@@ -48,6 +48,7 @@ typedef enum {
ARROW,
MDASH,
ELLIPSIS,
MU,
_SPECIAL_GLYPH_MAX
} SpecialGlyph;