1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include <perftest/perftest.h>
6 #include <zircon/syscalls.h>
7 
8 namespace {
9 
10 // Performance test for zx_clock_get_monotonic().  This is worth
11 // testing because it is a very commonly called syscall.  The kernel's
12 // implementation of the syscall is non-trivial and can be rather slow on
13 // some machines/VMs.
ClockGetMonotonicTest()14 bool ClockGetMonotonicTest() {
15     zx_clock_get_monotonic();
16     return true;
17 }
18 
ClockGetUtcTest()19 bool ClockGetUtcTest() {
20     zx_clock_get(ZX_CLOCK_UTC);
21     return true;
22 }
23 
ClockGetThreadTest()24 bool ClockGetThreadTest() {
25     zx_clock_get(ZX_CLOCK_THREAD);
26     return true;
27 }
28 
TicksGetTest()29 bool TicksGetTest() {
30     zx_ticks_get();
31     return true;
32 }
33 
RegisterTests()34 void RegisterTests() {
35     perftest::RegisterSimpleTest<ClockGetMonotonicTest>("ClockGetMonotonic");
36     perftest::RegisterSimpleTest<ClockGetUtcTest>("ClockGetUtc");
37     perftest::RegisterSimpleTest<ClockGetThreadTest>("ClockGetThread");
38     perftest::RegisterSimpleTest<TicksGetTest>("TicksGet");
39 }
40 PERFTEST_CTOR(RegisterTests);
41 
42 }  // namespace
43