Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
});
});
}, 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);
});
}
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();
});
}
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();
});
});
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 {
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();
};
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})
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
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`);
};
const onStart = () => {
startTime = microtime.now();
processedSignatures = 0;
numberOfRuns = 0;
};
const onComplete = (event) => {