Skip to content

Commit

Permalink
Fixed lint problems.
Browse files Browse the repository at this point in the history
Added button to start the test, instead starting it automatically, so CI does not wait for it.
Changed structure a bit, again.
Removed existing `editorinit.html` test to prevent confusion.
  • Loading branch information
scofalik committed Oct 3, 2024
1 parent 1bd2430 commit 6ff5c40
Show file tree
Hide file tree
Showing 18 changed files with 97 additions and 93 deletions.
5 changes: 5 additions & 0 deletions tests/_data/generated/formatting-long-paragraphs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

// Creates 40 paragraphs, each with a 1000 of text nodes, each text node is wrapped in an HTML tag that will be converted to text attribute.
// This is a counterpart data set to `formatting-short-paragraphs` where both tests have same total number of text nodes, but
// we observed that longer paragraphs have significant negative impact on editor performance.
Expand Down
5 changes: 5 additions & 0 deletions tests/_data/generated/formatting-short-paragraphs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

// Creates 800 paragraphs, each with a 50 of text nodes, each text node is wrapped in an HTML tag that will be converted to text attribute.
// This test how text formatting affects the editor loading speed.
export default function makeData() {
Expand Down
5 changes: 5 additions & 0 deletions tests/_data/generated/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

import paragraphs from './paragraphs.js';
import lists from './lists.js';
import tableHuge from './table-huge.js';
Expand Down
8 changes: 7 additions & 1 deletion tests/_data/generated/inline-styles.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

// Creates 30 paragraphs, each with a 1000 of text nodes, half of the text nodes is wrapped in a span with inline styles.
export default function makeData() {
let initialData = '';
Expand All @@ -7,7 +12,8 @@ export default function makeData() {

for ( let j = 0; j < 1000; j++ ) {
if ( j % 2 === 0 ) {
initialData += '<span style="font-weight:bold;font-style:italic;text-decoration:underline;color:#808080;font-family: Arial;background:#EEEEEE;">Lorem ipsum dolor</span>';
initialData += '<span style="font-weight:bold;font-style:italic;text-decoration:underline;color:#808080;' +
'font-family: Arial;background:#EEEEEE;">Lorem ipsum dolor</span>';
} else {
initialData += ' sit amet. ';
}
Expand Down
5 changes: 5 additions & 0 deletions tests/_data/generated/lists.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

// Creates multiple, nested lists, for a total of 3000 list items. Text in lists is simple, short, non-formatted text.
// This tests editor performance when huge lists are in the content.
// Below data creates 100 pages when copy-pasted to Google Docs (default page settings).
Expand Down
7 changes: 6 additions & 1 deletion tests/_data/generated/paragraphs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

// This is the most basic performance test, where we load many paragraphs (5000) and fill them with reasonable text volume, no formatting.
// Below data creates 400 pages when copy-pasted to Google Docs (default page settings).
export default function makeData() {
Expand All @@ -9,7 +14,7 @@ export default function makeData() {
'Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. ' +
'Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. ' +
'Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. ' +
'</p>'
'</p>';
}

return initialData;
Expand Down
7 changes: 6 additions & 1 deletion tests/_data/generated/table-huge.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

// Creates one table with 2000 rows and 10 columns, total 20000 cells.
// This tests editor performance when huge tables are in content.
export default function makeData() {
let initialData = '';

initialData += '<table>'
initialData += '<table>';

for ( let i = 0; i < 2000; i++ ) {
initialData += '<tr>';
Expand Down
7 changes: 6 additions & 1 deletion tests/_data/generated/tables-many-smaller.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

// Creates 40 smaller tables with 50 rows and 10 columns each, total 20000 cells.
// This is a counterpart data set for `table-huge` to see if it is just about cells quantity, or maybe longer tables have other problems.
export default function makeData() {
let initialData = '';

for ( let t = 0; t < 40; t++ ) {
initialData += '<table>'
initialData += '<table>';

for ( let i = 0; i < 50; i++ ) {
initialData += '<tr>';
Expand Down
5 changes: 5 additions & 0 deletions tests/_utils/performance-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment.js';
import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset.js';
import AutoImage from '@ckeditor/ckeditor5-image/src/autoimage.js';
Expand Down
27 changes: 0 additions & 27 deletions tests/manual/performance/editorinit.html

This file was deleted.

33 changes: 0 additions & 33 deletions tests/manual/performance/editorinit.js

This file was deleted.

7 changes: 0 additions & 7 deletions tests/manual/performance/editorinit.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@
}'>
</head>

<button id="btnStart">Start</button>

<div id="editor"></div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

/* globals console, window, document */

import config from '../../../_utils/performance-config.js';
import allDataSets from '../../../_data/generated/index.js';
import config from '../../_utils/performance-config.js';
import allDataSets from '../../_data/generated/index.js';
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor.js';

const initialData = allDataSets.paragraphs();
Expand All @@ -15,13 +15,21 @@ const editorElement = document.querySelector( '#editor' );

const startTime = window.performance.now();

ClassicEditor
.create( editorElement, finalConfig )
.then( () => {
const testTime = window.performance.now() - startTime;
function startTest() {
ClassicEditor
.create( editorElement, finalConfig )
.then( () => {
const testTime = window.performance.now() - startTime;

console.log( testTime );
} )
.catch( err => {
console.error( err.stack );
} );
console.log( testTime );
} )
.catch( err => {
console.error( err.stack );
} );
}

document.getElementById( 'btnStart' ).addEventListener( 'click', () => {
document.getElementById( 'btnStart' ).remove();

startTest();
} );
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
}'>
</head>

<button id="btnStart">Start</button>

<div id="status"></div>

<div id="editor"></div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* globals console, window, document */
/* globals console, window, document, sessionStorage, navigator, alert */

import config from '../../../_utils/performance-config.js';
import allDataSets from '../../../_data/generated/index.js';
import config from '../../_utils/performance-config.js';
import allDataSets from '../../_data/generated/index.js';
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor.js';

// TEST CONFIG.
Expand All @@ -27,11 +27,19 @@ const dataSetNames = Object.keys( dataSets );
run();

function run() {
const btnEl = document.getElementById( 'btnStart' );

if ( !isStarted() ) {
startTests();
}
btnEl.addEventListener( 'click', () => {
btnEl.remove();

performTest();
setupTests();
performTest();
} );
} else {
btnEl.remove();
performTest();
}
}

function performTest() {
Expand Down Expand Up @@ -63,7 +71,8 @@ function setStatus() {
const dataSetName = getCurrentDataSetName();
const tryNumber = sessionStorage.getItem( 'performanceTestTryNumber' );

statusEl.innerHTML = `Dataset "${ dataSetName }" (${ dataSetIndex + 1 } / ${ dataSetNames.length }), try ${ tryNumber } / ${ TRIES_PER_DATA_SET }`;
statusEl.innerHTML = `Dataset "${ dataSetName }" (${ dataSetIndex + 1 } / ${ dataSetNames.length }), ` +
`try ${ tryNumber } / ${ TRIES_PER_DATA_SET }`;
}

function getCurrentDataSetName() {
Expand All @@ -72,7 +81,7 @@ function getCurrentDataSetName() {
return dataSetNames[ dataSetIndex ];
}

function startTests() {
function setupTests() {
sessionStorage.setItem( 'performanceTestTryNumber', '1' );
sessionStorage.setItem( 'performanceTestResults', '{}' );
sessionStorage.setItem( 'performanceTestDataSetIndex', '0' );
Expand Down Expand Up @@ -149,7 +158,8 @@ function finishTests() {
console.log( resultsProcessed );

navigator.clipboard.writeText( resultsProcessed ).then( () => {
alert( "Tests finished!\nResults are copied to your clipboard\nYou can paste them to a spreadsheet" );
// eslint-disable-next-line no-alert
alert( 'Tests finished!\nResults are copied to your clipboard\nYou can paste them to a spreadsheet' );
} );
}

Expand All @@ -165,7 +175,10 @@ function prepareResults( dataObj ) {
const results = entry[ 1 ];

for ( let i = 0; i < REMOVE_OUTLIERS; i++ ) {
let maxV = 0, minV = Number.MAX_VALUE, maxJ = 0, minJ = 0;
let maxV = 0;
let minV = Number.MAX_VALUE;
let maxJ = 0;
let minJ = 0;

for ( let j = 0; j < results.length - 1; j++ ) {
if ( results[ j ] === '' ) {
Expand All @@ -188,6 +201,6 @@ function prepareResults( dataObj ) {
results[ minJ ] = '';
}

return dataSetName + "\t\t" + results.join( "\t" ) + "\n";
return dataSetName + '\t\t' + results.join( '\t' ) + '\n';
} ).join( '' );
}
File renamed without changes.

0 comments on commit 6ff5c40

Please sign in to comment.