Skip to content

Instantly share code, notes, and snippets.

@gburd
gburd / duration.h
Last active September 6, 2022 03:38
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 <greg@burd.me>
*
* 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
*/