mirror of
https://github.com/zadam/trilium.git
synced 2024-09-20 15:45:58 +08:00
measuring and logging time to compute content hash and consistency checks
This commit is contained in:
parent
c776f298f2
commit
3585982758
|
@ -83,6 +83,8 @@ async function runSyncRowChecks(table, key, errorList) {
|
||||||
async function runChecks() {
|
async function runChecks() {
|
||||||
const errorList = [];
|
const errorList = [];
|
||||||
|
|
||||||
|
const startTime = new Date();
|
||||||
|
|
||||||
await runCheck(`
|
await runCheck(`
|
||||||
SELECT
|
SELECT
|
||||||
note_id
|
note_id
|
||||||
|
@ -170,13 +172,15 @@ async function runChecks() {
|
||||||
await checkTreeCycles(errorList);
|
await checkTreeCycles(errorList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const elapsedTimeMs = new Date().getTime() - startTime.getTime();
|
||||||
|
|
||||||
if (errorList.length > 0) {
|
if (errorList.length > 0) {
|
||||||
log.info("Consistency checks failed with these errors: " + JSON.stringify(errorList));
|
log.info(`Consistency checks failed (took ${elapsedTimeMs}ms) with these errors: ` + JSON.stringify(errorList));
|
||||||
|
|
||||||
messaging.sendMessageToAllClients({type: 'consistency-checks-failed'});
|
messaging.sendMessageToAllClients({type: 'consistency-checks-failed'});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.info("All consistency checks passed.");
|
log.info(`All consistency checks passed (took ${elapsedTimeMs}ms)`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const sql = require('./sql');
|
const sql = require('./sql');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const options = require('./options');
|
const options = require('./options');
|
||||||
|
const log = require('./log');
|
||||||
|
|
||||||
function getHash(rows) {
|
function getHash(rows) {
|
||||||
let hash = '';
|
let hash = '';
|
||||||
|
@ -13,9 +14,11 @@ function getHash(rows) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getHashes() {
|
async function getHashes() {
|
||||||
|
const startTime = new Date();
|
||||||
|
|
||||||
const optionsQuestionMarks = Array(options.SYNCED_OPTIONS.length).fill('?').join(',');
|
const optionsQuestionMarks = Array(options.SYNCED_OPTIONS.length).fill('?').join(',');
|
||||||
|
|
||||||
return {
|
const hashes = {
|
||||||
notes: getHash(await sql.getAll(`SELECT
|
notes: getHash(await sql.getAll(`SELECT
|
||||||
note_id,
|
note_id,
|
||||||
note_title,
|
note_title,
|
||||||
|
@ -62,6 +65,12 @@ async function getHashes() {
|
||||||
WHERE opt_name IN (${optionsQuestionMarks})
|
WHERE opt_name IN (${optionsQuestionMarks})
|
||||||
ORDER BY opt_name`, options.SYNCED_OPTIONS))
|
ORDER BY opt_name`, options.SYNCED_OPTIONS))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const elapseTimeMs = new Date().getTime() - startTime.getTime();
|
||||||
|
|
||||||
|
log.info(`Content hash computation took ${elapseTimeMs}ms`);
|
||||||
|
|
||||||
|
return hashes;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
Loading…
Reference in a new issue