node-microtime

Get the current time in microseconds

  • 所有者: wadey/node-microtime
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

node-microtime

Travis Build
AppVeyor Build
npm
npm

Date.now() will only give you accuracy in milliseconds. This module calls
gettimeofday(2) to get the time in microseconds and provides it in a few
different formats. The same warning from that function applies:
The resolution of the system clock is hardware dependent, and the time may
be updated continuously or in ``ticks.''

N-API Support

As of version 3.0.0, this library is built using the N-API library. This should allow you to upgrade to newer versions of Node.js without having to reinstall / rebuild this library.

Version 3.0.0 and later also bundle prebuilt binaries for common systems in
the npm package itself. These will be used if the version of Node you are using
supports N-API (>= v6.14.2), otherwise the binary will be recompiled on install.

Installation

npm install microtime

Usage

microtime.now()

Get the current time in microseconds as an integer.

microtime.nowDouble()

Get the current time in seconds as a floating point number with microsecond
accuracy (similar to time.time() in Python and Time.now.to_f in Ruby).

microtime.nowStruct()

Get the current time and return as a list with seconds and microseconds (matching the return value of gettimeofday(2)).

Example

> var microtime = require('microtime')
> microtime.now()
1297448895297028
> microtime.nowDouble()
1297448897.600976
> microtime.nowStruct()
[ 1297448902, 753875 ]

Estimating clock resolution

Starting with version 0.1.3, there is a test script that tries to guess the clock resolution. You can run it with npm test microtime. Example output:

microtime.now() = 1298960083489806
microtime.nowDouble() = 1298960083.511521
microtime.nowStruct() = [ 1298960083, 511587 ]

Guessing clock resolution...
Clock resolution observed: 1us

主要指标

概览
名称与所有者wadey/node-microtime
主编程语言C++
编程语言Python (语言数: 3)
平台
许可证MIT License
所有者活动
创建于2011-02-11 18:24:42
推送于2024-01-08 18:50:32
最后一次提交2023-09-08 13:17:10
发布数39
最新版本名称v3.1.1 (发布于 2022-08-11 21:48:41)
第一版名称0.1.1 (发布于 )
用户参与
星数601
关注者数12
派生数45
提交数193
已启用问题?
问题数54
打开的问题数3
拉请求数11
打开的拉请求数6
关闭的拉请求数11
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?