aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Guo <robertguo@me.com>2018-03-02 06:22:03 -0500
committerDominic Hamon <dominichamon@users.noreply.github.com>2018-03-02 03:22:03 -0800
commitff2c255af5bb2fc2e5cd3b3685f0c6283117ce73 (patch)
tree1f9fb5b1a9aad0774a5e47c168c69f9e03dd0254
parent56f52ee228783547f544d9ac4a533574b9010e3f (diff)
downloadgoogle-benchmark-ff2c255af5bb2fc2e5cd3b3685f0c6283117ce73.tar.gz
Use STCK to get the CPU clock on s390x (#540)
-rw-r--r--AUTHORS1
-rw-r--r--CONTRIBUTORS1
-rw-r--r--src/cycleclock.h5
3 files changed, 7 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
index 4e4c4ed..e574b23 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -31,6 +31,7 @@ Kishan Kumar <kumar.kishan@outlook.com>
Lei Xu <eddyxu@gmail.com>
Matt Clarkson <mattyclarkson@gmail.com>
Maxim Vafin <maxvafin@gmail.com>
+MongoDB Inc.
Nick Hutchinson <nshutchinson@gmail.com>
Oleksandr Sochka <sasha.sochka@gmail.com>
Paul Redmond <paul.redmond@gmail.com>
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index c59134b..b942722 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -53,6 +53,7 @@ Pierre Phaneuf <pphaneuf@google.com>
Radoslav Yovchev <radoslav.tm@gmail.com>
Raul Marin <rmrodriguez@cartodb.com>
Ray Glover <ray.glover@uk.ibm.com>
+Robert Guo <robert.guo@mongodb.com>
Roman Lebedev <lebedev.ri@gmail.com>
Shuo Chen <chenshuo@chenshuo.com>
Tobias Ulvgård <tobias.ulvgard@dirac.se>
diff --git a/src/cycleclock.h b/src/cycleclock.h
index 4251fe4..3b376ac 100644
--- a/src/cycleclock.h
+++ b/src/cycleclock.h
@@ -159,6 +159,11 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() {
struct timeval tv;
gettimeofday(&tv, nullptr);
return static_cast<int64_t>(tv.tv_sec) * 1000000 + tv.tv_usec;
+#elif defined(__s390__) // Covers both s390 and s390x.
+ // Return the CPU clock.
+ uint64_t tsc;
+ asm("stck %0" : "=Q" (tsc) : : "cc");
+ return tsc;
#else
// The soft failover to a generic implementation is automatic only for ARM.
// For other platforms the developer is expected to make an attempt to create