timespec_get

Nanosecond-percision time using timespec_get

Pure Nim score 30/100 · tests present · docs generated

Summary

Latest Version Unknown
License 0BSD
CI Status Passing
Downloads 0
Last Indexed 2026-07-21 05:24

Installation

nimble install timespec_get
choosenim install timespec_get
git clone https://github.com/Matceporial/nim-timespec_get

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
timespec_get - - - - - - -

Source

Repository https://github.com/Matceporial/nim-timespec_get
Homepage https://github.com/Matceporial/nim-timespec_get
Documentation View Documentation
Registry Source nimble_official

README

timespec_get

Nanosecond-percision time using timespec_get of C11

Also, it should work on C++, but I don't know which version or what requirements it would have. I tested on C++ and it worked though.

API:

type
  timespec* = tuple[sec: int64, nsec: int32]

proc timespec_get*(): timespec
# Returns timespec with seconds and nanoseconds since start of the epoch

Example:

test1.nim:

import timespec_get
import os

var a = timespec_get()
sleep 70
var b = timespec_get()
echo b.nsec - a.nsec

License

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.