diff options
author | Pierre Ossman <ossman@cendio.se> | 2017-02-24 12:33:09 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2017-02-24 12:34:27 +0100 |
commit | 921f6c86ba2a6761ac4f640dd36903dc8bb9eed7 (patch) | |
tree | 6d8359699444ae08ffd82a27a387266aed13d76e /common | |
parent | 2e7c744426e4dff6c630e973a1464df814f24abe (diff) | |
download | tigervnc-921f6c86ba2a6761ac4f640dd36903dc8bb9eed7.tar.gz tigervnc-921f6c86ba2a6761ac4f640dd36903dc8bb9eed7.zip |
Display performance statistics in viewer
Adds an optional graph to the viewer to display current frame rate,
pixel rate and network bandwidth. Makes it easier to debug and test
performance related issues.
Diffstat (limited to 'common')
-rw-r--r-- | common/rfb/util.cxx | 14 | ||||
-rw-r--r-- | common/rfb/util.h | 4 |
2 files changed, 10 insertions, 8 deletions
diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx index aec45f61..22e00ffc 100644 --- a/common/rfb/util.cxx +++ b/common/rfb/util.cxx @@ -139,7 +139,7 @@ namespace rfb { static size_t doPrefix(long long value, const char *unit, char *buffer, size_t maxlen, unsigned divisor, const char **prefixes, - size_t prefixCount) { + size_t prefixCount, int precision) { double newValue; size_t prefix, len; @@ -152,7 +152,7 @@ namespace rfb { prefix++; } - len = snprintf(buffer, maxlen, "%g %s%s", newValue, + len = snprintf(buffer, maxlen, "%.*g %s%s", precision, newValue, (prefix == 0) ? "" : prefixes[prefix-1], unit); buffer[maxlen-1] = '\0'; @@ -165,14 +165,16 @@ namespace rfb { { "Ki", "Mi", "Gi", "Ti", "Pi", "Ei", "Zi", "Yi" }; size_t siPrefix(long long value, const char *unit, - char *buffer, size_t maxlen) { + char *buffer, size_t maxlen, int precision) { return doPrefix(value, unit, buffer, maxlen, 1000, siPrefixes, - sizeof(siPrefixes)/sizeof(*siPrefixes)); + sizeof(siPrefixes)/sizeof(*siPrefixes), + precision); } size_t iecPrefix(long long value, const char *unit, - char *buffer, size_t maxlen) { + char *buffer, size_t maxlen, int precision) { return doPrefix(value, unit, buffer, maxlen, 1024, iecPrefixes, - sizeof(iecPrefixes)/sizeof(*iecPrefixes)); + sizeof(iecPrefixes)/sizeof(*iecPrefixes), + precision); } }; diff --git a/common/rfb/util.h b/common/rfb/util.h index 9ad17720..e9114c3d 100644 --- a/common/rfb/util.h +++ b/common/rfb/util.h @@ -99,9 +99,9 @@ namespace rfb { unsigned msSince(const struct timeval *then); size_t siPrefix(long long value, const char *unit, - char *buffer, size_t maxlen); + char *buffer, size_t maxlen, int precision=6); size_t iecPrefix(long long value, const char *unit, - char *buffer, size_t maxlen); + char *buffer, size_t maxlen, int precision=6); } // Some platforms (e.g. Windows) include max() and min() macros in their |