fix(core): update

This commit is contained in:
2020-03-01 13:50:28 +00:00
parent c8fc842869
commit a5151b6c89
4 changed files with 25 additions and 21 deletions

View File

@ -22,6 +22,8 @@ export class SmartSSR {
}
public async renderPage(urlArg: string) {
const overallTimeMeasurement = new plugins.smarttime.HrtMeasurement();
overallTimeMeasurement.start();
const resultDeferred = plugins.smartpromise.defer<string>();
const context = await this.browser.createIncognitoBrowserContext();
const page = await context.newPage();
@ -41,11 +43,18 @@ export class SmartSSR {
);
});
const renderTimeMeasurement = new plugins.smarttime.HrtMeasurement();
renderTimeMeasurement.start();
await page.goto(urlArg);
const result = await resultDeferred.promise;
page.close().then(async () => {
await context.close();
});
renderTimeMeasurement.stop();
// lets clean up async
context.close();
overallTimeMeasurement.stop();
console.log(`Overall it took ${overallTimeMeasurement.milliSeconds} milliseconds to render ${urlArg}`);
console.log(`The rendering alone took ${renderTimeMeasurement.milliSeconds} milliseconds for ${urlArg}`)
return result;
}
}

View File

@ -8,5 +8,6 @@ import * as smartdelay from '@pushrocks/smartdelay';
import * as smartfile from '@pushrocks/smartfile';
import * as smartpuppeteer from '@pushrocks/smartpuppeteer';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smarttime from '@pushrocks/smarttime';
export { smartdelay, smartfile, smartpuppeteer, smartpromise };
export { smartdelay, smartfile, smartpuppeteer, smartpromise, smarttime };