mirror of
https://github.com/LucasDower/ObjToSchematic.git
synced 2025-12-11 20:15:30 +01:00
Added option to show timings on headless runs
This commit is contained in:
parent
cdd57c0054
commit
f837b56898
@ -38,11 +38,22 @@ export const LOG_WARN = (...data: any[]) => {
|
||||
Logger.Get.logToFile(...data);
|
||||
};
|
||||
|
||||
/* eslint-disable no-console */
|
||||
export const TIME_START = (label: string) => {
|
||||
if (Logger.Get.isLOGTIMEEnabled()) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.time(label);
|
||||
}
|
||||
};
|
||||
|
||||
export const TIME_END = (label: string) => {
|
||||
if (Logger.Get.isLOGTIMEEnabled()) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.timeEnd(label);
|
||||
}
|
||||
};
|
||||
|
||||
/* eslint-disable-next-line no-console */
|
||||
export const LOG_ERROR = console.error;
|
||||
export const TIME_START = console.time;
|
||||
export const TIME_END = console.timeEnd;
|
||||
/* eslint-disable */
|
||||
|
||||
export class Logger {
|
||||
/* Singleton */
|
||||
@ -54,6 +65,7 @@ export class Logger {
|
||||
private _enabledLOG: boolean;
|
||||
private _enabledLOGMAJOR: boolean;
|
||||
private _enabledLOGWARN: boolean;
|
||||
private _enabledLOGTIME: boolean;
|
||||
|
||||
private _logStream?: fs.WriteStream;
|
||||
|
||||
@ -61,6 +73,7 @@ export class Logger {
|
||||
this._enabledLOG = false;
|
||||
this._enabledLOGMAJOR = false;
|
||||
this._enabledLOGWARN = false;
|
||||
this._enabledLOGTIME = false;
|
||||
|
||||
FileUtil.mkdirSyncIfNotExist(AppPaths.Get.logs);
|
||||
if (AppConfig.LOG_TO_FILE) {
|
||||
@ -96,6 +109,14 @@ export class Logger {
|
||||
this._enabledLOGWARN = false;
|
||||
}
|
||||
|
||||
public enableLOGTIME() {
|
||||
this._enabledLOGTIME = true;
|
||||
}
|
||||
|
||||
public disableLOGTIME() {
|
||||
this._enabledLOGTIME = false;
|
||||
}
|
||||
|
||||
public isLOGEnabled() {
|
||||
return this._enabledLOG;
|
||||
}
|
||||
@ -107,4 +128,8 @@ export class Logger {
|
||||
public isLOGWARNEnabled() {
|
||||
return this._enabledLOGWARN;
|
||||
}
|
||||
|
||||
public isLOGTIMEEnabled() {
|
||||
return this._enabledLOGTIME;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ const baseConfig: THeadlessConfig = {
|
||||
debug: {
|
||||
showLogs: false,
|
||||
showWarnings: false,
|
||||
showTimings: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ const baseConfig: THeadlessConfig = {
|
||||
debug: {
|
||||
showLogs: false,
|
||||
showWarnings: false,
|
||||
showTimings: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ const baseConfig: THeadlessConfig = {
|
||||
debug: {
|
||||
showLogs: false,
|
||||
showWarnings: false,
|
||||
showTimings: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -30,6 +30,7 @@ const baseConfig: THeadlessConfig = {
|
||||
debug: {
|
||||
showLogs: false,
|
||||
showWarnings: false,
|
||||
showTimings: false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@ -28,5 +28,6 @@ export const headlessConfig: THeadlessConfig = {
|
||||
debug: {
|
||||
showLogs: true,
|
||||
showWarnings: true,
|
||||
showTimings: true,
|
||||
},
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { StatusHandler } from '../src/status';
|
||||
import { LOG_MAJOR, Logger } from '../src/util/log_util';
|
||||
import { LOG_MAJOR, Logger, TIME_END, TIME_START } from '../src/util/log_util';
|
||||
import { WorkerClient } from '../src/worker_client';
|
||||
import { AssignParams, ExportParams, ImportParams, VoxeliseParams } from '../src/worker_types';
|
||||
|
||||
@ -11,6 +11,7 @@ export type THeadlessConfig = {
|
||||
debug: {
|
||||
showLogs: boolean,
|
||||
showWarnings: boolean,
|
||||
showTimings: boolean,
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,25 +22,35 @@ export function runHeadless(headlessConfig: THeadlessConfig) {
|
||||
if (headlessConfig.debug.showWarnings) {
|
||||
Logger.Get.enableLOGWARN();
|
||||
}
|
||||
if (headlessConfig.debug.showTimings) {
|
||||
Logger.Get.enableLOGTIME();
|
||||
}
|
||||
|
||||
const worker = WorkerClient.Get;
|
||||
{
|
||||
LOG_MAJOR('Importing...');
|
||||
TIME_START('[TIMER] Importer');
|
||||
LOG_MAJOR('\nImporting...');
|
||||
worker.import(headlessConfig.import);
|
||||
StatusHandler.Get.dump().clear();
|
||||
TIME_END('[TIMER] Importer');
|
||||
}
|
||||
{
|
||||
LOG_MAJOR('Voxelising...');
|
||||
TIME_START('[TIMER] Voxeliser');
|
||||
LOG_MAJOR('\nVoxelising...');
|
||||
worker.voxelise(headlessConfig.voxelise);
|
||||
StatusHandler.Get.dump().clear();
|
||||
TIME_END('[TIMER] Voxeliser');
|
||||
}
|
||||
{
|
||||
LOG_MAJOR('Assigning...');
|
||||
TIME_START('[TIMER] Assigner');
|
||||
LOG_MAJOR('\nAssigning...');
|
||||
worker.assign(headlessConfig.assign);
|
||||
StatusHandler.Get.dump().clear();
|
||||
TIME_END('[TIMER] Assigner');
|
||||
}
|
||||
{
|
||||
LOG_MAJOR('Exporting...');
|
||||
TIME_START('[TIMER] Exporter');
|
||||
LOG_MAJOR('\nExporting...');
|
||||
/**
|
||||
* The OBJExporter is unique in that it uses the actual render buffer used by WebGL
|
||||
* to create its data, in headless mode this render buffer is not created so we must
|
||||
@ -53,5 +64,6 @@ export function runHeadless(headlessConfig: THeadlessConfig) {
|
||||
}
|
||||
worker.export(headlessConfig.export);
|
||||
StatusHandler.Get.dump().clear();
|
||||
TIME_END('[TIMER] Exporter');
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,5 +8,5 @@ void async function main() {
|
||||
|
||||
runHeadless(headlessConfig);
|
||||
|
||||
LOG_MAJOR('Finished!');
|
||||
LOG_MAJOR('\nFinished!');
|
||||
}();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user