blob: 731b2f850ad733356fa05b7f969564460ead5e30 [file] [log] [blame]
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <unistd.h>
#include <perftest/perftest.h>
namespace {
// Measure the time taken by getpid().
// On Linux, this acts as a test to measure syscall overhead. getpid() is
// a good example of a very simple syscall.
// Note that glibc's getpid() wrapper function used to cache the process ID
// in user space, but that caching was removed in 2017, and the wrapper
// currently always does a syscall invocation. See:
bool Getpid() {
pid_t pid = getpid();
return true;
void RegisterTests() { perftest::RegisterSimpleTest<Getpid>("Getpid"); }
} // namespace