refactor: move to new timing API
MODIFY
lib/basedriver/driver.js
lib/basedriver/driver.js
@@ -158,8 +158,8 @@ class BaseDriver extends Protocol {
if (!this._eventHistory[eventName]) {
this._eventHistory[eventName] = [];
}
- let ts = Date.now();
- let logTime = (new Date(ts)).toTimeString();
+ const ts = Date.now();
+ const logTime = (new Date(ts)).toTimeString();
this._eventHistory[eventName].push(ts);
log.debug(`Event '${eventName}' logged at ${ts} (${logTime})`);
}

MODIFY
lib/basedriver/helpers.js
lib/basedriver/helpers.js
@@ -4,7 +4,7 @@ import url from 'url';
import logger from './logger';
import _fs from 'fs';
import B from 'bluebird';
-import { tempDir, fs, util, zip } from 'appium-support';
+import { tempDir, fs, util, zip, timing } from 'appium-support';
import request from 'request';
import asyncRequest from 'request-promise';
import LRU from 'lru-cache';
@@ -243,7 +243,7 @@ async function configureApp (app, supportedAppExtensions) {
async function downloadApp (app, targetPath) {
const {href} = url.parse(app);
- const started = process.hrtime();
+ const timer = new timing.Timer().start();
try {
// don't use request-promise here, we need streams
await new B((resolve, reject) => {
@@ -261,8 +261,7 @@ async function downloadApp (app, targetPath) {
} catch (err) {
throw new Error(`Problem downloading app from url ${href}: ${err.message}`);
}
- const [seconds, ns] = process.hrtime(started);
- const secondsElapsed = seconds + ns / 1e09;
+ const secondsElapsed = timer.getDuration().asSeconds;
const {size} = await fs.stat(targetPath);
logger.debug(`'${href}' (${util.toReadableSizeString(size)}) ` +
`has been downloaded to '${targetPath}' in ${secondsElapsed.toFixed(3)}s`);

MODIFY
package.json
package.json
],
"dependencies": {
"@babel/runtime": "^7.0.0",
- "appium-support": "^2.36.0",
+ "appium-support": "^2.37.0",
"async-lock": "^1.0.0",
"asyncbox": "^2.3.1",
"bluebird": "^3.5.3",

refactor: move to new timing API (#377)