How to use the hrtime function from process

Find comprehensive JavaScript process.hrtime code examples handpicked from public code repositorys.

126
127
128
129
130
131
132
133
134
135

// Now for each worker pool we ask the providers to do stuff
const workerPools = (await this.db.fns.get_worker_pools_with_capacity_and_counts_by_state(null, null))
  .map(row => WorkerPool.fromDb(row));
for (const workerPool of workerPools) {
  const start = process.hrtime.bigint();
  const { providerId, previousProviderIds, workerPoolId } = workerPool;
  const provider = this.providers.get(providerId);
  if (!provider) {
    this.monitor.warning(
fork icon238
star icon321
watch icon19

632
633
634
635
636
637
638
639
640
641

for (let name in commands) {
    let cmd = commands[name];
    let cwd = test.directory + '/src/koffi';

    let start = process.hrtime.bigint();
    let ret = await exec_remote(machine, cmd, cwd);
    let time = Number((process.hrtime.bigint() - start) / 1000000n);

    if (ret.code === 0) {
fork icon7
star icon35
watch icon0

25
26
27
28
29
30
31
32
33
34
    assert.isArray(start);

    var now = Date.now();
    while (Date.now() - now < 2000);

    var diff = process.hrtime(start);

    assert.notLessThan(diff[0], 1);
    assert.notGreaterThan(diff[0], 2);
});
fork icon311
star icon0
watch icon0

16
17
18
19
20
21
22
23
24
25
26
27
]);


// helper methods
const extractCommandName = command => Object.keys(command)[0];
const calculateDurationInMs = started => {
  const hrtime = process.hrtime(started);
  return (hrtime[0] * 1e9 + hrtime[1]) / 1e6;
};


const namespace = command => command.ns;
fork icon0
star icon0
watch icon2

+ 2 other calls in file

185
186
187
188
189
190
191
192
193
194
let isDev = process.env.NODE_ENV === "development";
let libCheck = !isDev;
let emitDeclarations = !isDev;
let clean = !isDev;

let buildStart = hrtime();

await build({
  globalName: "SchemaShield",
  entryPoint: "./lib/index.ts",
fork icon0
star icon0
watch icon1

+ 7 other calls in file

13
14
15
16
17
18
19
20
21
22
23
24
const date = date_ob.getDate();
const month = date_ob.getMonth() + 1;
const year = date_ob.getFullYear();


// cpu usage
const startTime = process.hrtime();
const startUsage = process.cpuUsage();


while (Date.now() - ts < 500);

fork icon0
star icon0
watch icon0

+ 3 other calls in file

232
233
234
235
236
237
238
239
240
    result = whereItExplodes(graph, [])
} catch(e) {
    result = naiveResult
}

const colorItEndTime = process.hrtime.bigint()

if (debug) {
    displayGrid(grid)
fork icon0
star icon0
watch icon0

+ 2 other calls in file

140
141
142
143
144
145
146
147
148
149
150
151
/* ========================================================================== */
/* UTILITIES FOR STATIC METHODS                                               */
/* ========================================================================== */


/* Nanoseconds & clock sequence for V1 */
var nanoTimee = process.hrtime();
var clockSeq = (process.pid * nanoTimee[1]) & 0x0ffff;


function uuidbuffer(mac) {

fork icon0
star icon0
watch icon0

+ 3 other calls in file

129
130
131
132
133
134
135
136
137
}

// query Comunica
const client = new Client({context: combinedContext, queryEngine: this.comunicaQueryEngine});
logger.info(`GraphQL LD query and additional context:\n${graphQlLdQuery}\n${additionalContextString}`);
const t1 = process.hrtime.bigint();
let data = (await client.query({query: graphQlLdQuery})).data;
const t2 = process.hrtime.bigint();
logger.info(`GraphQL LD query executed in ${(t2-t1)/1000000n} milliseconds.`);
fork icon0
star icon0
watch icon0

280
281
282
283
284
285
286
287
288
289
    // request cancellation if there is not finished job
    _this.cancellationToken.requestCancellation();
    _this.compiler.hooks.forkTsCheckerCancel.call(_this.cancellationToken);
}
_this.checkDone = false;
_this.started = process.hrtime();
// create new token for current job
_this.cancellationToken = new CancellationToken_1.CancellationToken(undefined, undefined);
if (!_this.service || !_this.service.connected) {
    _this.spawnService();
fork icon0
star icon0
watch icon0

+ 2 other calls in file