From b48052ff320f1a68aac317158c4c757a70b14f04 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 22 May 2021 15:19:56 -0400 Subject: [PATCH] Add timing information to schema-validate.js (#1696) --- dev/schema-validate.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dev/schema-validate.js b/dev/schema-validate.js index 1cb69618..45285700 100644 --- a/dev/schema-validate.js +++ b/dev/schema-validate.js @@ -16,6 +16,7 @@ */ const fs = require('fs'); +const {performance} = require('perf_hooks'); const {VM} = require('./vm'); const vm = new VM(); @@ -41,13 +42,17 @@ function main() { const schema = JSON.parse(schemaSource); for (const dataFileName of args.slice(1)) { + const start = performance.now(); try { console.log(`Validating ${dataFileName}...`); const dataSource = fs.readFileSync(dataFileName, {encoding: 'utf8'}); const data = JSON.parse(dataSource); new JsonSchemaValidator().validate(data, schema); - console.log('No issues found'); + const end = performance.now(); + console.log(`No issues detected (${((end - start) / 1000).toFixed(2)}s)`); } catch (e) { + const end = performance.now(); + console.log(`Encountered an error (${((end - start) / 1000).toFixed(2)}s)`); console.warn(e); } }