Added number of server boots to test reporting

no issue

- this commit adds a counter for the number of boots we do in tests
- which therefore allows us to calculate the average boot time we
  experience
- only useful for debugging test performance
This commit is contained in:
Daniel Lockyer 2021-11-25 07:36:50 +01:00
parent ff89cd74bc
commit 617fec71cb
No known key found for this signature in database
GPG Key ID: D21186F0B47295AD

View File

@ -31,6 +31,7 @@ const context = require('./fixtures/context');
let ghostServer;
let existingData = {};
let totalStartTime = 0;
let totalBoots = 0;
/**
* Because we use ObjectID we don't know the ID of fixtures ahead of time
@ -210,8 +211,10 @@ const startGhost = async (options) => {
// Reporting
const totalTime = Date.now() - startTime;
totalStartTime += totalTime;
totalBoots += 1;
const averageBootTime = Math.round(totalStartTime / totalBoots);
debug(`Started Ghost in ${totalTime / 1000}s`);
debug(`Accumulated start time is ${totalStartTime / 1000}s`);
debug(`Accumulated start time across ${totalBoots} boots is ${totalStartTime / 1000}s (average = ${averageBootTime}ms)`);
return ghostServer;
};