From 31ed3318d033422e051321bfa56b359770391c68 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Tue, 7 Mar 2023 11:55:41 +0100 Subject: [PATCH] Fix console.time calls --- src/distributions/adopt/installer.ts | 10 ++++------ src/distributions/corretto/installer.ts | 10 ++++------ src/distributions/liberica/installer.ts | 10 ++++------ src/distributions/microsoft/installer.ts | 12 ++++++++++++ src/distributions/temurin/installer.ts | 10 ++++------ src/distributions/zulu/installer.ts | 10 ++++------ 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/distributions/adopt/installer.ts b/src/distributions/adopt/installer.ts index 08d667b5..9887b789 100644 --- a/src/distributions/adopt/installer.ts +++ b/src/distributions/adopt/installer.ts @@ -4,7 +4,6 @@ import * as tc from '@actions/tool-cache'; import fs from 'fs'; import path from 'path'; import semver from 'semver'; -import {performance} from 'perf_hooks'; import {JavaBase} from '../base-installer'; import {IAdoptAvailableVersions} from './models'; @@ -111,7 +110,9 @@ export class AdoptDistribution extends JavaBase { const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions const releaseType = this.stable ? 'ga' : 'ea'; - const startTime = performance.now(); + if (core.isDebug()) { + console.time('Retrieving available versions for Adopt took'); // eslint-disable-line no-console + } const baseRequestArguments = [ `project=jdk`, @@ -153,11 +154,8 @@ export class AdoptDistribution extends JavaBase { } if (core.isDebug()) { - const resultTime = ((performance.now() - startTime) / 1000).toFixed(1); core.startGroup('Print information about available versions'); - core.debug( - `Retrieving available versions for Adopt took: ${resultTime} s` - ); + console.timeEnd('Retrieving available versions for Adopt took'); // eslint-disable-line no-console core.debug(`Available versions: [${availableVersions.length}]`); core.debug( availableVersions.map(item => item.version_data.semver).join(', ') diff --git a/src/distributions/corretto/installer.ts b/src/distributions/corretto/installer.ts index c403dfeb..38384cb7 100644 --- a/src/distributions/corretto/installer.ts +++ b/src/distributions/corretto/installer.ts @@ -2,7 +2,6 @@ import * as core from '@actions/core'; import * as tc from '@actions/tool-cache'; import fs from 'fs'; import path from 'path'; -import {performance} from 'perf_hooks'; import {extractJdkFile, getDownloadArchiveExtension} from '../../util'; import {JavaBase} from '../base-installer'; import { @@ -89,7 +88,9 @@ export class CorrettoDistribution extends JavaBase { const arch = this.distributionArchitecture(); const imageType = this.packageType; - const startTime = performance.now(); + if (core.isDebug()) { + console.time('Retrieving available versions for Coretto took'); // eslint-disable-line no-console + } const availableVersionsUrl = 'https://corretto.github.io/corretto-downloads/latest_links/indexmap_with_checksum.json'; @@ -110,11 +111,8 @@ export class CorrettoDistribution extends JavaBase { this.getAvailableVersionsForPlatform(eligibleVersions); if (core.isDebug()) { - const resultTime = ((performance.now() - startTime) / 1000).toFixed(1); core.startGroup('Print information about available versions'); - core.debug( - `Retrieving available versions for Coretto took: ${resultTime} s` - ); + console.timeEnd('Retrieving available versions for Coretto took'); // eslint-disable-line no-console core.debug(`Available versions: [${availableVersions.length}]`); core.debug( availableVersions diff --git a/src/distributions/liberica/installer.ts b/src/distributions/liberica/installer.ts index cc22d708..313f29ea 100644 --- a/src/distributions/liberica/installer.ts +++ b/src/distributions/liberica/installer.ts @@ -15,7 +15,6 @@ import {ArchitectureOptions, LibericaVersion, OsVersions} from './models'; import * as tc from '@actions/tool-cache'; import fs from 'fs'; import path from 'path'; -import {performance} from 'perf_hooks'; const supportedPlatform = `'linux', 'linux-musl', 'macos', 'solaris', 'windows'`; @@ -81,7 +80,9 @@ export class LibericaDistributions extends JavaBase { } private async getAvailableVersions(): Promise { - const startTime = performance.now(); + if (core.isDebug()) { + console.time('Retrieving available versions for Liberica took'); // eslint-disable-line no-console + } const url = this.prepareAvailableVersionsUrl(); core.debug(`Gathering available versions from '${url}'`); @@ -90,11 +91,8 @@ export class LibericaDistributions extends JavaBase { (await this.http.getJson(url)).result ?? []; if (core.isDebug()) { - const resultTime = ((performance.now() - startTime) / 1000).toFixed(1); core.startGroup('Print information about available versions'); - core.debug( - `Retrieving available versions for Liberica took: ${resultTime} s` - ); + console.timeEnd('Retrieving available versions for Liberica took'); // eslint-disable-line no-console core.debug(`Available versions: [${availableVersions.length}]`); core.debug(availableVersions.map(item => item.version).join(', ')); core.endGroup(); diff --git a/src/distributions/microsoft/installer.ts b/src/distributions/microsoft/installer.ts index f6649e64..8b6a7a38 100644 --- a/src/distributions/microsoft/installer.ts +++ b/src/distributions/microsoft/installer.ts @@ -103,6 +103,10 @@ export class MicrosoftDistributions extends JavaBase { let response: ITypedResponse | null = null; + if (core.isDebug()) { + console.time('Retrieving available versions for Microsoft took'); // eslint-disable-line no-console + } + try { response = await this.http.getJson(fileUrl, headers); if (!response.result) { @@ -119,6 +123,14 @@ export class MicrosoftDistributions extends JavaBase { releases = response.result; } + if (core.isDebug() && releases) { + core.startGroup('Print information about available versions'); + console.timeEnd('Retrieving available versions for Microsoft took'); // eslint-disable-line no-console + core.debug(`Available versions: [${releases.length}]`); + core.debug(releases.map(item => item.version).join(', ')); + core.endGroup(); + } + return releases; } } diff --git a/src/distributions/temurin/installer.ts b/src/distributions/temurin/installer.ts index e4b9e07c..4a1989bc 100644 --- a/src/distributions/temurin/installer.ts +++ b/src/distributions/temurin/installer.ts @@ -4,7 +4,6 @@ import * as tc from '@actions/tool-cache'; import fs from 'fs'; import path from 'path'; import semver from 'semver'; -import {performance} from 'perf_hooks'; import {JavaBase} from '../base-installer'; import {ITemurinAvailableVersions} from './models'; @@ -109,7 +108,9 @@ export class TemurinDistribution extends JavaBase { const versionRange = encodeURI('[1.0,100.0]'); // retrieve all available versions const releaseType = this.stable ? 'ga' : 'ea'; - const startTime = performance.now(); + if (core.isDebug()) { + console.time('Retrieving available versions for Temurin took'); // eslint-disable-line no-console + } const baseRequestArguments = [ `project=jdk`, @@ -153,11 +154,8 @@ export class TemurinDistribution extends JavaBase { } if (core.isDebug()) { - const resultTime = ((performance.now() - startTime) / 1000).toFixed(1); core.startGroup('Print information about available versions'); - core.debug( - `Retrieving available versions for Temurin took: ${resultTime} s` - ); + console.timeEnd('Retrieving available versions for Temurin took'); // eslint-disable-line no-console core.debug(`Available versions: [${availableVersions.length}]`); core.debug( availableVersions.map(item => item.version_data.semver).join(', ') diff --git a/src/distributions/zulu/installer.ts b/src/distributions/zulu/installer.ts index 27fed234..dec9dbfe 100644 --- a/src/distributions/zulu/installer.ts +++ b/src/distributions/zulu/installer.ts @@ -4,7 +4,6 @@ import * as tc from '@actions/tool-cache'; import path from 'path'; import fs from 'fs'; import semver from 'semver'; -import {performance} from 'perf_hooks'; import {JavaBase} from '../base-installer'; import {IZuluVersions} from './models'; @@ -104,7 +103,9 @@ export class ZuluDistribution extends JavaBase { const javafx = features?.includes('fx') ?? false; const releaseStatus = this.stable ? 'ga' : 'ea'; - const startTime = performance.now(); + if (core.isDebug()) { + console.time('Retrieving available versions for Zulu took'); // eslint-disable-line no-console + } const requestArguments = [ `os=${platform}`, @@ -129,11 +130,8 @@ export class ZuluDistribution extends JavaBase { .result ?? []; if (core.isDebug()) { - const resultTime = ((performance.now() - startTime) / 1000).toFixed(1); core.startGroup('Print information about available versions'); - core.debug( - `Retrieving available versions for Azul took: ${resultTime} s` - ); + console.timeEnd('Retrieving available versions for Zulu took'); // eslint-disable-line no-console core.debug(`Available versions: [${availableVersions.length}]`); core.debug( availableVersions.map(item => item.jdk_version.join('.')).join(', ')