Skip to content

Commit

Permalink
[FIX] logs: log performance information at debug level
Browse files Browse the repository at this point in the history
3b1657f introduced the logging of performance information in the logs.
This could be useful in some case, but often flooded the console for
nothing.

This commit changes the log level to debug, so that it is not displayed
by default.

Unfortunately console.group is not meant for debug level (it still
group the messages, but the group title is always displayed even if
debug logs are not displayed). Replaced it by good'ol
`console.debug("#####")` to mark sections.

closes #5112

Task: 0
Signed-off-by: Vincent Schippefilt (vsc) <[email protected]>
  • Loading branch information
hokolomopo committed Oct 22, 2024
1 parent 75906d4 commit 504b907
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/collaborative/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class Session extends EventBus<CollaborativeEvent> {
this.onMessageReceived(message);
}
this.isReplayingInitialRevisions = false;
console.info("Replayed", numberOfCommands, "commands in", performance.now() - start, "ms");
console.debug("Replayed", numberOfCommands, "commands in", performance.now() - start, "ms");
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/migrations/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function load(data?: any, verboseImport?: boolean): WorkbookData {
if (!data) {
return createEmptyWorkbookData();
}
console.group("Loading data");
console.debug("### Loading data ###");
const start = performance.now();
if (data["[Content_Types].xml"]) {
const reader = new XlsxReader(data);
Expand All @@ -57,13 +57,13 @@ export function load(data?: any, verboseImport?: boolean): WorkbookData {
// apply migrations, if needed
if ("version" in data) {
if (data.version < CURRENT_VERSION) {
console.info("Migrating data from version", data.version);
console.debug("Migrating data from version", data.version);
data = migrate(data);
}
}
data = repairData(data);
console.info("Data loaded in", performance.now() - start, "ms");
console.groupEnd();
console.debug("Data loaded in", performance.now() - start, "ms");
console.debug("###");
return data;
}

Expand All @@ -84,7 +84,7 @@ function migrate(data: any): WorkbookData {
for (let i = index; i < MIGRATIONS.length; i++) {
data = MIGRATIONS[i].applyMigration(data);
}
console.info("Data migrated in", performance.now() - start, "ms");
console.debug("Data migrated in", performance.now() - start, "ms");
return data;
}

Expand Down
12 changes: 6 additions & 6 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class Model extends EventBus<any> implements CommandDispatcher {
verboseImport = true
) {
const start = performance.now();
console.group("Model creation");
console.debug("##### Model creation #####");
super();
setDefaultTranslationMethod();

Expand Down Expand Up @@ -284,16 +284,16 @@ export class Model extends EventBus<any> implements CommandDispatcher {

if (config.snapshotRequested) {
const startSnapshot = performance.now();
console.info("Snapshot requested");
console.debug("Snapshot requested");
this.session.snapshot(this.exportData());
this.garbageCollectExternalResources();
console.info("Snapshot taken in", performance.now() - startSnapshot, "ms");
console.debug("Snapshot taken in", performance.now() - startSnapshot, "ms");
}
// mark all models as "raw", so they will not be turned into reactive objects
// by owl, since we do not rely on reactivity
markRaw(this);
console.info("Model created in", performance.now() - start, "ms");
console.groupEnd();
console.debug("Model created in", performance.now() - start, "ms");
console.debug("######");
}

joinSession() {
Expand Down Expand Up @@ -538,7 +538,7 @@ export class Model extends EventBus<any> implements CommandDispatcher {
this.finalize();
const time = performance.now() - start;
if (time > 5) {
console.info(type, time, "ms");
console.debug(type, time, "ms");
}
});
this.session.save(command, commands, changes);
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/ui_core_views/cell_evaluation/evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class Evaluator {
cellsToCompute.addMany(arrayFormulasPositions);
cellsToCompute.addMany(this.getCellsDependingOn(arrayFormulasPositions));
this.evaluate(cellsToCompute);
console.info("evaluate Cells", performance.now() - start, "ms");
console.debug("evaluate Cells", performance.now() - start, "ms");
}

private getArrayFormulasImpactedByChangesOf(
Expand Down Expand Up @@ -193,7 +193,7 @@ export class Evaluator {
const start = performance.now();
this.evaluatedCells = new PositionMap();
this.evaluate(this.getAllCells());
console.info("evaluate all cells", performance.now() - start, "ms");
console.debug("evaluate all cells", performance.now() - start, "ms");
}

evaluateFormulaResult(
Expand Down
4 changes: 1 addition & 3 deletions tests/setup/jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ beforeAll(() => {
},
});

console.info = () => {};
console.group = () => {};
console.groupEnd = () => {};
console.debug = () => {};
});

beforeEach(() => {
Expand Down

0 comments on commit 504b907

Please sign in to comment.