microtime.wasm
v0.1.0
Published
get the current time
Downloads
5
Readme
microtime.wasm
WebAssembly implementation of the microtime module.
Note, this module is a proof of concept and likely should not be used. Emscripten implements the C function gettimeofday(2)
as a call to JavaScript's Date.now()
. This defeats the original purpose of microtime
, which was to obtain better than the millisecond accuracy provided by Date.now()
.
Basic Usage
'use strict';
const { now, nowDouble, nowStruct } = require('microtime.wasm');
console.log(now());
console.log(nowDouble());
console.log(nowStruct());
API
microtime.wasm
exports the following methods.
now()
- Arguments
- None.
- Returns
result
(number) - The current time in microseconds as an integer.
nowDouble()
- Arguments
- None.
- Returns
result
(number) - The current time in seconds as a floating point number.
nowStruct()
- Arguments
- None.
- Returns
result
(array) - The current time as a two element array. The first element represents the number of seconds. The second element represents the number of microseconds. This matches the return value ofgettimeofday(2)
.