Skip to content

Commit

Permalink
Merge pull request Marklogic-retired#208 in PROD/explorer-ui from ~DN…
Browse files Browse the repository at this point in the history
…ICHOLS/explorer-ui:performance to develop

* commit 'b735a0bdedbd27a1b89de54a2af8f439d47424ff':
  DHFPROD-3775: New performance reports added.
  DHFPROD-3775: New performance reports added.
  • Loading branch information
marklogic-builder committed Jan 31, 2020
2 parents 22b7854 + b735a0b commit 9a6c671
Show file tree
Hide file tree
Showing 11 changed files with 159 additions and 117 deletions.
2 changes: 2 additions & 0 deletions performance_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ RUNNING TESTS:
3. run "node index.js TESTNAME"
ex: "node index.js browseDocs"

*** RUN index_all.js INSTEAD OF index.js TO GET A FULL PERFORMANCE REPORT ***

BROWSEDOCS.js:
1. This script simply browses x amount pages of documents without selecting any facets.
2. You can change the number of pages it browses by changing the const variable "browseDocs" at the top of the script.
Expand Down
18 changes: 2 additions & 16 deletions performance_tests/allFacets.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ const numCollections = 2; //number of collection facets that will be selected
const numFlows = 1; //number of flow facets that will be selected
const numSteps = 1; //number of flow facets that will be selected

async function collections(page) {
const performanceTiming = JSON.parse(
await page.evaluate(() => JSON.stringify(window.performance.timing))
);
async function allFacets(page) {

await page.waitForSelector('#hub-properties > .ant-collapse-header')
await page.click('#hub-properties > .ant-collapse-header')
Expand Down Expand Up @@ -86,19 +83,8 @@ async function collections(page) {
return
}
await page.click('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
console.log(extractDataFromPerformanceTiming(performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'))
}


return extractDataFromPerformanceTiming(
performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'
);
}

module.exports = collections;
module.exports = allFacets;
14 changes: 0 additions & 14 deletions performance_tests/browseDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ const { extractDataFromPerformanceTiming } = require('./perfHelper');
const numPages = 10;

async function browseDocs(page) {
const performanceTiming = JSON.parse(
await page.evaluate(() => JSON.stringify(window.performance.timing))
);

for (var i = 2; i < numPages; i++) {
try {
Expand All @@ -16,19 +13,8 @@ async function browseDocs(page) {
return
}
await page.click('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
console.log(extractDataFromPerformanceTiming(performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'))
await page.waitFor(1000)
}

return extractDataFromPerformanceTiming(
performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'
);
}

module.exports = browseDocs;
15 changes: 0 additions & 15 deletions performance_tests/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ const numPages = 10; //number of pages the script will browse
const numCollections = 2; //number of collection facets that will be selected

async function collections(page) {
const performanceTiming = JSON.parse(
await page.evaluate(() => JSON.stringify(window.performance.timing))
);

await page.waitForSelector('#hub-properties')
await page.click('#hub-properties')

Expand Down Expand Up @@ -36,19 +32,8 @@ async function collections(page) {
await page.waitFor(1000)
await page.waitForSelector('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
await page.click('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
console.log(extractDataFromPerformanceTiming(performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'))
}


return extractDataFromPerformanceTiming(
performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'
);
}

module.exports = collections;
16 changes: 0 additions & 16 deletions performance_tests/createdOn.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ const numPages = 10;

async function createdOn(page) {

const performanceTiming = JSON.parse(
await page.evaluate(() => JSON.stringify(window.performance.timing))
);

await page.waitForSelector('#hub-properties > .ant-collapse-header')
await page.click('#hub-properties > .ant-collapse-header')
await page.waitFor(1000)
Expand All @@ -29,19 +25,7 @@ async function createdOn(page) {
await page.waitFor(1000)
await page.waitForSelector('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
await page.click('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
console.log(extractDataFromPerformanceTiming(
performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'))
}

return extractDataFromPerformanceTiming(
performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'
);
}

module.exports = createdOn;
14 changes: 0 additions & 14 deletions performance_tests/flows.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ const numPages = 10; //number of pages the script will browse
const numFlows = 1; //number of flow facets that will be selected

async function collections(page) {
const performanceTiming = JSON.parse(
await page.evaluate(() => JSON.stringify(window.performance.timing))
);

await page.waitForSelector('#hub-properties')
await page.click('#hub-properties')
Expand Down Expand Up @@ -35,19 +32,8 @@ async function collections(page) {
await page.waitFor(1000)
await page.waitForSelector('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
await page.click('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
console.log(extractDataFromPerformanceTiming(performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'))
}


return extractDataFromPerformanceTiming(
performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'
);
}

module.exports = collections;
81 changes: 55 additions & 26 deletions performance_tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,71 @@ const puppeteer = require('puppeteer');
const testPage = require('./' + process.argv.slice(2)[0]);

(async () => {
const browser = await puppeteer.launch({headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox']});
const page = await browser.newPage()
const browser = await puppeteer.launch({ignoreHTTPSErrors: true, headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox']});
const page = await browser.newPage()

await page.setCacheEnabled(false)
const navigationPromise = page.waitForNavigation({})
//await page.setCacheEnabled(false)
const navigationPromise = page.waitForNavigation({
waitUntil: 'networkidle0',
});

await page.goto('http://rh7-intel64-perf-4:3000');
process.on('unhandledRejection', error => {
console.log('unhandledRejection', error.message);
});
await page.goto('https://rh7v-10-dhf-stress-1:8443', { waitUntil: 'domcontentloaded' });
process.on('unhandledRejection', error => {
console.log('unhandledRejection', error.message);
});

new Promise((_, reject) => reject(new Error('error'))).
catch(error => {
console.log('caught', err.message);
});
new Promise((_, reject) => reject(new Error('error'))).
catch(error => {
console.log('caught', err.message);
});

await page.setViewport({ width: 1916, height: 997 })

await navigationPromise


await page.waitForSelector('.ant-col #username')
await page.click('.ant-col #username')

await page.type('.ant-col #username', 'admin')

await page.setViewport({ width: 1916, height: 997 })
await page.waitForSelector('.ant-col #password')
await page.click('.ant-col #password')

await navigationPromise
await page.type('.ant-col #password', 'admin')

await page.waitForSelector('.ant-row #submit')
await page.click('.ant-row #submit')

await page.waitForSelector('.ant-col #username')
await page.click('.ant-col #username')
await page.waitFor(5000)
await page.goto('https://rh7v-10-dhf-stress-1:8443/browse', { waitUntil: 'domcontentloaded' })
console.log(await testPage(page));

await page.type('.ant-col #username', 'admin')
console.log("\n==== performance.getEntries() ====\n");
console.log(
await page.evaluate( () =>
JSON.stringify(performance.getEntries()
.filter(e => e.entryType === 'resource')
.map(e => [e.name, e.duration]), null, " ")
)
);

await page.waitForSelector('.ant-col #password')
await page.click('.ant-col #password')
/* console.log("\n==== performance.toJSON() ====\n");
console.log(
await page.evaluate( () =>
JSON.stringify(performance.toJSON(), null, " ")
)
);
await page.type('.ant-col #password', 'admin')
console.log("\n==== page.metrics() ====\n");
const perf = await page.metrics();
console.log(
JSON.stringify(perf, null, " ")
);
await page.waitForSelector('.ant-row #submit')
await page.click('.ant-row #submit')
console.log("\n==== Devtools: Performance.getMetrics ====\n");
let performanceMetrics = await page._client.send('Performance.getMetrics');
console.log( performanceMetrics.metrics ); */

await page.waitFor(5000)
await page.goto('http://rh7-intel64-perf-4:3000/browse')
console.log(await testPage(page));
await browser.close()
await browser.close()
})()
70 changes: 70 additions & 0 deletions performance_tests/index_all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const puppeteer = require('puppeteer');
const testPage = require('./' + process.argv.slice(2)[0]);

(async () => {
const browser = await puppeteer.launch({ignoreHTTPSErrors: true, headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox']});
const page = await browser.newPage()

//await page.setCacheEnabled(false)
const navigationPromise = page.waitForNavigation({
waitUntil: 'networkidle0',
});

await page.goto('https://rh7v-10-dhf-stress-1:8443', { waitUntil: 'domcontentloaded' });
process.on('unhandledRejection', error => {
console.log('unhandledRejection', error.message);
});

new Promise((_, reject) => reject(new Error('error'))).
catch(error => {
console.log('caught', err.message);
});

await page.setViewport({ width: 1916, height: 997 })

await navigationPromise


await page.waitForSelector('.ant-col #username')
await page.click('.ant-col #username')

await page.type('.ant-col #username', 'admin')

await page.waitForSelector('.ant-col #password')
await page.click('.ant-col #password')

await page.type('.ant-col #password', 'admin')

await page.waitForSelector('.ant-row #submit')
await page.click('.ant-row #submit')

await page.waitFor(5000)
await page.goto('https://rh7v-10-dhf-stress-1:8443/browse', { waitUntil: 'domcontentloaded' })
console.log(await testPage(page));

console.log("\n==== performance.getEntries() ====\n");
console.log(
await page.evaluate( () =>
JSON.stringify(performance.getEntries(), null, " ")
)
);

console.log("\n==== performance.toJSON() ====\n");
console.log(
await page.evaluate( () =>
JSON.stringify(performance.toJSON(), null, " ")
)
);

console.log("\n==== page.metrics() ====\n");
const perf = await page.metrics();
console.log(
JSON.stringify(perf, null, " ")
);

console.log("\n==== Devtools: Performance.getMetrics ====\n");
let performanceMetrics = await page._client.send('Performance.getMetrics');
console.log( performanceMetrics.metrics );

await browser.close()
})()
12 changes: 12 additions & 0 deletions performance_tests/run_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
echo "Running: Browse Docs"
node index.js browseDocs.js > browseDoc_timing
echo "Running: Search"
node index.js search.js > search_timing
echo "Running: Collections"
node index.js collections.js > collection_timing
echo "Running: Steps"
node index.js steps.js > steps_timing
echo "Running: Flows"
node index.js flows.js > flows_timing
echo "Running: All Facets"
node index.js allFacets.js > allFacets_timing
16 changes: 16 additions & 0 deletions performance_tests/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { extractDataFromPerformanceTiming } = require('./perfHelper');

async function search(page) {

await page.waitForSelector('[class*=search-bar_searchInput] > .ant-input-search > .ant-input-wrapper > .ant-input-search > .ant-input')
await page.click('[class*=search-bar_searchInput] > .ant-input-search > .ant-input-wrapper > .ant-input-search > .ant-input')

await page.waitFor(3000)
await page.type('[class*=search-bar_searchInput] > .ant-input-search > .ant-input-wrapper > .ant-input-search > .ant-input', 'the')

await page.waitFor(2000)
await page.click('[class*=search-bar_searchInput] > .ant-input-search > .ant-input-wrapper > .ant-input-group-addon > .ant-btn')

}

module.exports = search;
18 changes: 2 additions & 16 deletions performance_tests/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ const { extractDataFromPerformanceTiming } = require('./perfHelper');
const numPages = 10; //number of pages the script will browse
const numSteps = 1; //number of step facets that will be selected

async function collections(page) {
const performanceTiming = JSON.parse(
await page.evaluate(() => JSON.stringify(window.performance.timing))
);
async function steps(page) {

await page.waitForSelector('#hub-properties')
await page.click('#hub-properties')
Expand Down Expand Up @@ -35,19 +32,8 @@ async function collections(page) {
await page.waitFor(1000)
await page.waitForSelector('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
await page.click('[class*=Browse_searchBar] > [class*=search-pagination_searchPaginationContainer]:nth-child(3) > .ant-pagination > .ant-pagination-item-' + i + ' > a')
console.log(extractDataFromPerformanceTiming(performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'))
}


return extractDataFromPerformanceTiming(
performanceTiming,
'responseEnd',
'domInteractive',
'loadEventEnd'
);
}

module.exports = collections;
module.exports = steps;

0 comments on commit 9a6c671

Please sign in to comment.