How to use the microtime.now function in microtime

To help you get started, we’ve selected a few microtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github christkv / mongodb-schema-simulator / lib / common / scenarios / workloads.js View on Github external
bulk.execute(options, function(err, d) {
          if(err) return callback(err);

          // Operation end time
          var endTime = microtime.now();

          // Log the time taken for the operation
          services.log('second', 'insert', {
              start: startTime
            , end: endTime
            , time: endTime - startTime
          });

          callback();
        });
      });
github christkv / mongodb-schema-simulator / lib / common / scenarios / carts_reservations.js View on Github external
}, options, function(err, r) {
                // Get end time of the cart
                var endTime = microtime.now();
                services.log('second', 'cart_reservation_successful', {
                    start: startTime
                  , end: endTime
                  , time: endTime - startTime
                });

                // Finish the execution
                callback(err, r);
              });
            }
github christkv / mongodb-schema-simulator / lib / common / scenarios / queues.js View on Github external
queue.publish(Math.round(priorityRange * Math.random()), workObject, options, function(err) {
        if(err) return callback(err);

        // Operation end time
        var endTime = microtime.now();

        // Log the time taken for the operation
        services.log('second', 'publish_to_queues', {
            start: startTime
          , end: endTime
          , time: endTime - startTime
        });

        callback();
      });
    }
github christkv / mongodb-schema-simulator / lib / common / scenarios / topics.js View on Github external
topic.publish(doc, function(err) {
          if(err) return callback(err);

          // Operation end time
          var endTime = microtime.now();

          // Log the time taken for the operation
          services.log('second', 'publish_to_topics', {
              start: startTime
            , end: endTime
            , time: endTime - startTime
          });

          callback();
        });
      });
github christkv / mongodb-schema-simulator / lib / common / scenarios / timeseries.js View on Github external
timeserie.inc(t, 1, options, function() {
          // Operation end time
          var endTime = microtime.now();

          // Log the time taken for the operation
          services.log('second', 'timeseries', {
              start: startTime
            , end: endTime
            , time: endTime - startTime
          });

          callback();
        });
      } else {
github pelias-deprecated / fences-builder / src / OSMAreaBuilder.js View on Github external
OSMAreaBuilder.prototype.start = function start() {
  this._resetStats();

  this._startTime = microtime.now();

  // invoke the engine with all the specified handlers
  osmium.apply(
    this._reader,
    this._location_handler,
    this._handler,
    this._mp.handler(this._handler));

  this._reader.close();
};
github Medium / shepherd / lib / BuilderInstance.js View on Github external
BuilderInstance.prototype.build = function (inputData, callback, callbackScope) {
  if (this._config.validateDependencies) this.validateDependencies(Object.keys(inputData))

  // clone the input data to keep it pristine
  var data = {
    _config: this._config,
    _trace: this._trace.bind(this),
    _resolve: this._resolve.bind(this),
    _traceId: inputData._traceId || Date.now() + '.' + Math.floor(Math.random() * 10000)
  }
  for (var key in inputData) data[key] = inputData[key]
  var startTime
  var outputs = this._outputs

  // resolve all needed outputs
  if (data._config.handlers.timing && outputs.length) startTime = microtime.now()
  data._trace('debug', {traceId: data._traceId, action: 'starting build()', outputs: outputs})

  var promise
  if (outputs.length) {
    var resolvers = []
    for (var i = 0; i < outputs.length; i += 1) {
      resolvers.push(data._resolve(data, outputs[i]))
    }
    promise = Q.all(resolvers)
  } else {
    promise = Q.resolve([])
  }

  var promise = promise
  .then(function (results) {
    data._trace('debug', {traceId: data._traceId, action: 'finished build()', outputs: outputs})
github Medium / shepherd / lib2 / BuilderInstance.js View on Github external
BuilderInstance.prototype.build = function (inputData, callback) {
  if (this._config.validateDependencies) this.validateDependencies(Object.keys(inputData))

  // clone the input data to keep it pristine
  var data = {}
  for (var key in inputData) {
    data[key] = inputData[key]
  }
  if (!data._traceId) data._traceId = Date.now() + '.' + Math.floor(Math.random() * 10000)
  var startTime

  // resolve all needed outputs
  if (this._config.handlers.timing) startTime = microtime.now()
  this._trace('debug', {traceId: data._traceId, action: 'starting build()', outputs: this._outputs})

  var promise = Q.allResolved(this._outputs.map(function (output) {
    return this._resolve(data, output)
  }.bind(this)))
  .then(function (promises) {
    this._trace('debug', {traceId: data._traceId, action: 'finished build()', outputs: this._outputs})
    if (this._config.handlers.timing) this._config.handlers.timing('build.' + this._outputs ? this._outputs.join(',') : 'EMPTY', microtime.now() - startTime)

    // convert our promises to a map *or* throw an error if we have one
    var response = {}
    for (var i = 0; i < promises.length; i += 1) {
      if (!promises[i].isFulfilled()) throw promises[i].valueOf().exception
      response[this._outputs[i]] = promises[i].valueOf()
    }
    return response
github guggero / bip-schnorr / test / schnorr.benchmark.js View on Github external
const onComplete = (event) => {
  const elapsedTime = microtime.now() - startTime;
  const signaturesPerSecond = Math.round(processedSignatures / (elapsedTime / 1000000));
  const microsecondsPerRun = Math.round(elapsedTime / numberOfRuns);
  console.log(`${event.target} ${microsecondsPerRun} us/op ${signaturesPerSecond} sig/s`);
};
github guggero / bip-schnorr / test / schnorr.benchmark.js View on Github external
const onStart = () => {
  startTime = microtime.now();
  processedSignatures = 0;
  numberOfRuns = 0;
};
const onComplete = (event) => {

microtime

Get the current time in microseconds

MIT
Latest version published 2 years ago

Package Health Score

50 / 100
Full package analysis

Popular microtime functions