-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
35 lines (32 loc) · 1.54 KB
/
Copy pathindex.js
File metadata and controls
35 lines (32 loc) · 1.54 KB
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
var clock_gettimejs = require('./build/Release/clock_gettime');
module.exports.clock_gettime = clock_gettimejs.clock_gettimejs.clock_gettime;
module.exports.clock_settime = clock_gettimejs.clock_gettimejs.clock_settime;
module.exports.clock_getres = clock_gettimejs.clock_gettimejs.clock_getres;
module.exports.CLOCK_REALTIME = clock_gettimejs.CLOCK_REALTIME;
module.exports.CLOCK_REALTIME_COARSE = clock_gettimejs.CLOCK_REALTIME_COARSE;
module.exports.CLOCK_MONOTONIC = clock_gettimejs.CLOCK_MONOTONIC;
module.exports.CLOCK_MONOTONIC_COARSE = clock_gettimejs.CLOCK_MONOTONIC_COARSE;
module.exports.CLOCK_MONOTONIC_RAW = clock_gettimejs.CLOCK_MONOTONIC_RAW;
module.exports.CLOCK_BOOTTIME = clock_gettimejs.CLOCK_BOOTTIME;
module.exports.CLOCK_PROCESS_CPUTIME_ID = clock_gettimejs.CLOCK_PROCESS_CPUTIME_ID;
module.exports.CLOCK_THREAD_CPUTIME_ID = clock_gettimejs.CLOCK_THREAD_CPUTIME_ID;
module.exports.diff = function(start, end) {
var temp = {};
if ((end.tv_nsec - start.tv_nsec) < 0) {
temp.tv_sec = end.tv_sec - start.tv_sec - 1;
temp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
} else {
temp.tv_sec = end.tv_sec - start.tv_sec;
temp.tv_nsec = end.tv_nsec - start.tv_nsec;
}
return temp;
};
module.exports.to_ns = function(ts) {
return ts.tv_sec * 1000000000 + ts.tv_nsec;
};
module.exports.to_us = function(ts) {
return ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
};
module.exports.to_ms = function(ts) {
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
};