diff --git a/lib/datasource/rubygems/get-rubygems-org.ts b/lib/datasource/rubygems/get-rubygems-org.ts index bda6288b349d19b7f6368d54006105174bbf7bc3..489a47f89bddf380f1b9975eb6378f9b3dc5e32e 100644 --- a/lib/datasource/rubygems/get-rubygems-org.ts +++ b/lib/datasource/rubygems/get-rubygems-org.ts @@ -1,4 +1,3 @@ -import { hrtime } from 'process'; import { logger } from '../../logger'; import { Http } from '../../util/http'; import { DatasourceError, ReleaseResult } from '../common'; @@ -24,11 +23,10 @@ async function updateRubyGemsVersions(): Promise<void> { let newLines: string; try { logger.debug('Rubygems: Fetching rubygems.org versions'); - const startTime = hrtime(); + const startTime = Date.now(); newLines = (await http.get(url, options)).body; - const duration = hrtime(startTime); - const seconds = Math.round(duration[0] + duration[1] / 1e9); - logger.debug({ seconds }, 'Rubygems: Fetched rubygems.org versions'); + const durationMs = Math.round(Date.now() - startTime); + logger.debug({ durationMs }, 'Rubygems: Fetched rubygems.org versions'); } catch (err) /* istanbul ignore next */ { if (err.statusCode !== 416) { contentLength = 0; diff --git a/lib/platform/git/storage.ts b/lib/platform/git/storage.ts index 04b1a22608c11d8078d73363309871e8e229f816..2aca6841e7adecc8e736412b994a6c5586dc8b18 100644 --- a/lib/platform/git/storage.ts +++ b/lib/platform/git/storage.ts @@ -1,6 +1,5 @@ import { join } from 'path'; import URL from 'url'; -import convertHrtime from 'convert-hrtime'; import fs from 'fs-extra'; import Git from 'simple-git/promise'; import { @@ -145,17 +144,14 @@ export class Storage { try { this._git = Git(cwd).silent(true); await this._git.raw(['remote', 'set-url', 'origin', config.url]); - const fetchStart = process.hrtime(); + const fetchStart = Date.now(); await this._git.fetch(['--depth=10']); await setBaseBranchToDefault(this._git); await this._resetToBranch(config.baseBranch); await this._cleanLocalBranches(); await this._git.raw(['remote', 'prune', 'origin']); - const fetchSeconds = - Math.round( - 1 + 10 * convertHrtime(process.hrtime(fetchStart)).seconds - ) / 10; - logger.debug({ fetchSeconds }, 'git fetch completed'); + const durationMs = Math.round(Date.now() - fetchStart); + logger.debug({ durationMs }, 'git fetch completed'); clone = false; } catch (err) /* istanbul ignore next */ { logger.error({ err }, 'git fetch error'); @@ -164,7 +160,7 @@ export class Storage { if (clone) { await fs.emptyDir(cwd); this._git = Git(cwd).silent(true); - const cloneStart = process.hrtime(); + const cloneStart = Date.now(); try { // clone only the default branch let opts = ['--depth=2']; @@ -178,10 +174,8 @@ export class Storage { logger.debug({ err }, 'git clone error'); throw new Error(PLATFORM_FAILURE); } - const seconds = - Math.round(1 + 10 * convertHrtime(process.hrtime(cloneStart)).seconds) / - 10; - logger.debug({ seconds }, 'git clone completed'); + const durationMs = Math.round(Date.now() - cloneStart); + logger.debug({ durationMs }, 'git clone completed'); } const submodules = await this.getSubmodules(); for (const submodule of submodules) { diff --git a/lib/util/exec/index.ts b/lib/util/exec/index.ts index f2618a4b87924995c9f5c0501997fbfd35260fec..27f60115a66e13241793d7e92a0478d1e9885606 100644 --- a/lib/util/exec/index.ts +++ b/lib/util/exec/index.ts @@ -1,6 +1,5 @@ import { ExecOptions as ChildProcessExecOptions } from 'child_process'; import { dirname, join } from 'path'; -import { hrtime } from 'process'; import { RenovateConfig } from '../../config/common'; import { logger } from '../../logger'; import { @@ -140,7 +139,7 @@ export async function exec( let res: ExecResult | null = null; for (const rawExecCommand of commands) { - const startTime = hrtime(); + const startTime = Date.now(); let timer; const { timeout } = rawExecOptions; if (useDocker) { @@ -168,13 +167,12 @@ export async function exec( throw err; } clearTimeout(timer); - const duration = hrtime(startTime); - const seconds = Math.round(duration[0] + duration[1] / 1e9); + const durationMs = Math.round(Date.now() - startTime); if (res) { logger.debug( { cmd: rawExecCommand, - seconds, + durationMs, stdout: res.stdout, stderr: res.stderr, }, diff --git a/lib/workers/repository/process/extract-update.ts b/lib/workers/repository/process/extract-update.ts index cdacbe3ada42b1306731e700c6f4fd0a166d2458..b446cfc52ef183ba4575fc2f177c18a99e24bf2b 100644 --- a/lib/workers/repository/process/extract-update.ts +++ b/lib/workers/repository/process/extract-update.ts @@ -1,4 +1,3 @@ -import { hrtime } from 'process'; import { RenovateConfig } from '../../../config'; import { logger } from '../../../logger'; import { PackageFile } from '../../../manager/common'; @@ -46,12 +45,11 @@ function extractStats(packageFiles: Record<string, PackageFile[]>): any { export async function extract(config: RenovateConfig): Promise<ExtractResult> { logger.debug('extractAndUpdate()'); - const startTime = hrtime(); + const startTime = Date.now(); const packageFiles = await extractAllDependencies(config); - const duration = hrtime(startTime); - const seconds = Math.round(duration[0] + duration[1] / 1e9); + const durationMs = Math.round(Date.now() - startTime); const stats = extractStats(packageFiles); - logger.info({ stats, seconds }, `Dependency extraction complete`); + logger.info({ stats, durationMs }, `Dependency extraction complete`); logger.trace({ config: packageFiles }, 'packageFiles'); await fetchUpdates(config, packageFiles); logger.debug({ config: packageFiles }, 'packageFiles with updates'); diff --git a/lib/workers/repository/process/fetch.ts b/lib/workers/repository/process/fetch.ts index 19a5289cf170a87668b0529b3ec184da25b01181..1b3daef5cc24e21901dd34bba5495460a4af62a0 100644 --- a/lib/workers/repository/process/fetch.ts +++ b/lib/workers/repository/process/fetch.ts @@ -1,4 +1,3 @@ -import { hrtime } from 'process'; import pAll from 'p-all'; import { ManagerConfig, @@ -115,12 +114,11 @@ export async function fetchUpdates( packageFiles: Record<string, PackageFile[]> ): Promise<void> { const managers = Object.keys(packageFiles); - const startTime = hrtime(); + const startTime = Date.now(); const allManagerJobs = managers.map((manager) => fetchManagerUpdates(config, packageFiles, manager) ); await Promise.all(allManagerJobs); - const duration = hrtime(startTime); - const seconds = Math.round(duration[0] + duration[1] / 1e9); - logger.info({ seconds }, 'Package releases lookups complete'); + const durationMs = Math.round(Date.now() - startTime); + logger.info({ durationMs }, 'Package releases lookups complete'); } diff --git a/package.json b/package.json index 70770311936c5d9c56c622e7cef59b1d9fe2100d..b40be85a83e51d4b68d12150d78309d1df569bc3 100644 --- a/package.json +++ b/package.json @@ -121,7 +121,6 @@ "clean-git-ref": "2.0.1", "commander": "5.1.0", "conventional-commits-detector": "1.0.2", - "convert-hrtime": "3.0.0", "deepmerge": "4.2.2", "delay": "4.3.0", "detect-indent": "6.0.0", diff --git a/yarn.lock b/yarn.lock index 3e1616e257679ec3dc9fc0d25175aeb51161a0b7..4bd80e9734ceeb0c75fa1958b55838651e8f8733 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2903,11 +2903,6 @@ conventional-commits-parser@^3.0.0, conventional-commits-parser@^3.0.7: through2 "^3.0.0" trim-off-newlines "^1.0.0" -convert-hrtime@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/convert-hrtime/-/convert-hrtime-3.0.0.tgz#62c7593f5809ca10be8da858a6d2f702bcda00aa" - integrity sha512-7V+KqSvMiHp8yWDuwfww06XleMWVVB9b9tURBx+G7UTADuo5hYPuowKloz4OzOqbPezxgo+fdQ1522WzPG4OeA== - convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442"