mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-06-16 03:04:53 -04:00
perf test
This commit is contained in:
parent
49ebba4d6c
commit
48ebc3af5a
2 changed files with 10 additions and 4 deletions
|
@ -5,8 +5,11 @@ const plugins = require('../../../static/js/pluginfw/plugin_defs');
|
||||||
const CachingMiddleware = require('../../utils/caching_middleware');
|
const CachingMiddleware = require('../../utils/caching_middleware');
|
||||||
const Yajsml = require('etherpad-yajsml');
|
const Yajsml = require('etherpad-yajsml');
|
||||||
const _ = require('underscore');
|
const _ = require('underscore');
|
||||||
|
const stats = require('../../stats');
|
||||||
|
|
||||||
exports.expressCreateServer = (hookName, args, cb) => {
|
exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
|
stats.gauge('minificationDuration', () => minificationDuration);
|
||||||
|
const preMinification = Date.now();
|
||||||
// Cache both minified and static.
|
// Cache both minified and static.
|
||||||
const assetCache = new CachingMiddleware();
|
const assetCache = new CachingMiddleware();
|
||||||
args.app.all(/\/javascripts\/(.*)/, assetCache.handle);
|
args.app.all(/\/javascripts\/(.*)/, assetCache.handle);
|
||||||
|
@ -18,6 +21,10 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
// Setup middleware that will package JavaScript files served by minify for
|
// Setup middleware that will package JavaScript files served by minify for
|
||||||
// CommonJS loader on the client-side.
|
// CommonJS loader on the client-side.
|
||||||
// Hostname "invalid.invalid" is a dummy value to allow parsing as a URI.
|
// Hostname "invalid.invalid" is a dummy value to allow parsing as a URI.
|
||||||
|
const minificationDuration = Date.now() - preMinification;
|
||||||
|
|
||||||
|
stats.gauge('YajsmlDuration', () => yajsmlDuration);
|
||||||
|
const preYajsml = Date.now();
|
||||||
const jsServer = new (Yajsml.Server)({
|
const jsServer = new (Yajsml.Server)({
|
||||||
rootPath: 'javascripts/src/',
|
rootPath: 'javascripts/src/',
|
||||||
rootURI: 'http://invalid.invalid/static/js/',
|
rootURI: 'http://invalid.invalid/static/js/',
|
||||||
|
@ -33,6 +40,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
jsServer.setAssociator(associator);
|
jsServer.setAssociator(associator);
|
||||||
|
|
||||||
args.app.use(jsServer.handle.bind(jsServer));
|
args.app.use(jsServer.handle.bind(jsServer));
|
||||||
|
const yajsmlDuration = Date.now() - preYajsml;
|
||||||
|
|
||||||
// serve plugin definitions
|
// serve plugin definitions
|
||||||
// not very static, but served here so that client can do
|
// not very static, but served here so that client can do
|
||||||
|
|
|
@ -62,12 +62,10 @@ exports.start = async () => {
|
||||||
|
|
||||||
// Performance stats gauges
|
// Performance stats gauges
|
||||||
// We use gauges because a reload might replace the value
|
// We use gauges because a reload might replace the value
|
||||||
stats.gauge('postNpmLoad', () => preNpmLoad);
|
stats.gauge('npmLoadDuration', () => postNpmLoad);
|
||||||
stats.gauge('postNpmLoad', () => postNpmLoad);
|
|
||||||
|
|
||||||
const preNpmLoad = Date.now() - stats.startTime;
|
const preNpmLoad = Date.now() - stats.startTime;
|
||||||
await util.promisify(npm.load)();
|
await util.promisify(npm.load)();
|
||||||
const postNpmLoad = Date.now() - stats.startTime;
|
const npmLoadDuration = Date.now() - stats.startTime;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
stats.gauge('dbInitDuration', () => dbInitDuration);
|
stats.gauge('dbInitDuration', () => dbInitDuration);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue