1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16export class TimeRecorder { 17 private lintStart = BigInt(0); 18 private lintEnd = BigInt(0); 19 private migrationStart = BigInt(0); 20 private migrationEnd = BigInt(0); 21 private isHomeCheckCount: boolean = false; 22 23 setHomeCheckCountStatus(isHomeCheckCount: boolean): void { 24 this.isHomeCheckCount = isHomeCheckCount; 25 } 26 27 getHomeCheckCountStatus(): boolean { 28 return this.isHomeCheckCount; 29 } 30 31 startScan(): void { 32 this.lintStart = process.hrtime.bigint(); 33 } 34 35 endScan(): void { 36 this.lintEnd = process.hrtime.bigint(); 37 } 38 39 startMigration(): void { 40 this.migrationStart = process.hrtime.bigint(); 41 } 42 43 endMigration(): void { 44 this.migrationEnd = process.hrtime.bigint(); 45 } 46 47 getScanTime(): string { 48 return `${(Number(this.lintEnd - this.lintStart) / 1000000000).toFixed(2)} s`; 49 } 50 51 getMigrationTime(): string { 52 return `${(Number(this.migrationEnd - this.migrationStart) / 1000000000).toFixed(2)} s`; 53 } 54} 55