aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/lib/strings/str_util.h
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2016-09-06 13:55:35 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-09-06 15:02:22 -0700
commit6e369da8b4a8668169cdd6a93c8a069a5a4888c2 (patch)
tree28c522a7fceecef070588ccb9197566d365e7373 /tensorflow/core/lib/strings/str_util.h
parent51a8d2e56a9af0d5501472c4f11cb03a9d6aba8c (diff)
Add new str_util::HumanReadableElapsedTime that formats a 'double seconds' value
using appropriate units based on the magnitude of the time interval, and add tests for this. Change: 132365945
Diffstat (limited to 'tensorflow/core/lib/strings/str_util.h')
-rw-r--r--tensorflow/core/lib/strings/str_util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/tensorflow/core/lib/strings/str_util.h b/tensorflow/core/lib/strings/str_util.h
index 4a519425d4..8198b7c541 100644
--- a/tensorflow/core/lib/strings/str_util.h
+++ b/tensorflow/core/lib/strings/str_util.h
@@ -80,6 +80,15 @@ string Uppercase(StringPiece s);
// set of characters that can be used as word boundaries.
void TitlecaseString(string* s, StringPiece delimiters);
+// Converts a time interval as double to a human readable
+// string. For example:
+// 0.001 -> "1 ms"
+// 10.0 -> "10 s"
+// 933120.0 -> "10.8 days"
+// 39420000.0 -> "1.25 years"
+// -10 -> "-10 s"
+string HumanReadableElapsedTime(double seconds);
+
// Join functionality
template <typename T>
string Join(const T& s, const char* sep);