-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
47 lines (42 loc) · 953 Bytes
/
test.js
File metadata and controls
47 lines (42 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict'
const tap = require('tap')
const sleep = require('atomic-sleep')
const {
hrtime2ns,
hrtime2us,
hrtime2ms,
hrtime2s
} = require('./')
tap.test('hrtime2ns', t => {
const start = process.hrtime()
sleep(205)
const end = process.hrtime(start)
const delta = hrtime2ns(end)
t.ok(delta >= 2e6, `value ${delta}`)
t.end()
})
tap.test('hrtime2us', t => {
const start = process.hrtime()
sleep(205)
const end = process.hrtime(start)
const delta = hrtime2us(end)
console.log(delta)
t.ok(delta >= 2e5, `value ${delta}`)
t.end()
})
tap.test('hrtime2ms', t => {
const start = process.hrtime()
sleep(205)
const end = process.hrtime(start)
const delta = hrtime2ms(end)
t.ok(delta >= 2e2, `value ${delta}`)
t.end()
})
tap.test('hrtime2s', t => {
const start = process.hrtime()
sleep(1050)
const end = process.hrtime(start)
const delta = hrtime2s(end)
t.ok(delta >= 1, `value ${delta}`)
t.end()
})