Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track additional values from prometheus metrics #15

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Run Theia
shell: bash
working-directory: ./theia
run: yarn browser start &
run: yarn browser start:debug &

- name: Run Performance Measurement
uses: GabrielBB/xvfb-action@v1
Expand Down
42 changes: 34 additions & 8 deletions scripts/performance-report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,29 @@ export async function generatePerformanceReport(path: string) {
fs.removeSync(reportPath);
}

const values = await readValuesFromHistory(path, ['process_cpu_seconds_total', 'playwright_total_time']);
const values = await readValuesFromHistory(path, [
'theia_measurements/frontend',
'theia_measurements/startContributions',
'theia_measurements/waitForDeployment',
'theia_measurements/revealShell',
'theia_measurements/deployPlugins',
'theia_measurements/syncPlugins',
'theia_measurements/loadPlugins',
'theia_measurements/startPlugins',
'process_cpu_seconds_total',
'playwright_total_time'
]);
const charts: string[] = [];
for (const [valueLabel, valueHistory] of values) {
const data = valueHistory.history.map(entry => ({ x: entry.entryLabel, y: entry.value }));
const valueId = valueLabel.replace('/', '_');
charts.push(`
<div class="chart">
<h2>${valueLabel}</h2>
<canvas id="${valueLabel}" style="width:100%;max-height: 500px;"></canvas>
<canvas id="${valueId}" style="width:100%;max-height: 500px;"></canvas>
<script>
const ctx${valueLabel} = document.getElementById('${valueLabel}');
new Chart(ctx${valueLabel}, {
const ctx${valueId} = document.getElementById('${valueId}');
new Chart(ctx${valueId}, {
type: 'line',
data: {
datasets: [{
Expand Down Expand Up @@ -249,15 +261,29 @@ export function toDate(fileName: string): Date {
return new Date(dateFragments[0], dateFragments[1], dateFragments[2], timeFragments[0], timeFragments[1], timeFragments[2]);
}

const nameAttribute = 'name="';
export async function readEntries(path: string, values: string[]): Promise<{ valueLabel: string, entryValue: number }[]> {
const entries: { valueLabel: string, entryValue: number }[] = [];
try {
const rl = readline.createInterface({ input: fs.createReadStream(path), crlfDelay: Infinity });
rl.on('line', (line) => {
rl.on('line', (line: string) => {
for (const valueLabel of values) {
if (line.startsWith(valueLabel + ' ')) {
const entryValue = Number.parseFloat(line.split(' ')[1]);
entries.push({ valueLabel, entryValue });
const positionOfSlashInValueLabel = valueLabel.indexOf('/');
const isComplexLabel = positionOfSlashInValueLabel > -1;
const expectedLineStartForValueLabel = !isComplexLabel ? valueLabel + ' ' : valueLabel.substring(0, positionOfSlashInValueLabel) + '{';
if (line.startsWith(expectedLineStartForValueLabel)) {
if (isComplexLabel && line.indexOf(nameAttribute) > -1) {
const valueName = valueLabel.substring(positionOfSlashInValueLabel + 1);
const lineStartingWithName = line.substring(line.indexOf(nameAttribute) + nameAttribute.length);
if (lineStartingWithName.startsWith(valueName)) {
const lineFragments = line.split(' ');
const entryValue = Number.parseFloat(lineFragments[lineFragments.length - 1]);
entries.push({ valueLabel, entryValue });
}
} else {
const entryValue = Number.parseFloat(line.split(' ')[1]);
entries.push({ valueLabel, entryValue });
}
}
}
});
Expand Down
Loading