Skip to content

Instantly share code, notes, and snippets.

@gburd
gburd / duration.h
Last active January 16, 2025 01:58
Measure the duration of things in C using either the real-time high-resolution nanosecond clock or CPU clock ticks via the RDTSC instruction.
/*
* Copyright (C) 2013, all rights reserved by Gregory Burd <[email protected]>
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* version 2 (MPLv2). If a copy of the MPL was not distributed with this file,
* you can obtain one at: http://mozilla.org/MPL/2.0/
*
* NOTES:
* - on some platforms this will require -lrt
*/