diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ed32496a49..82918d5fab 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -188,7 +188,7 @@ build-and-lint: - yarn lint - node scripts/check-packages.ts -test-performance: +bundle-size: extends: - .base-configuration - .test-allowed-branches @@ -609,6 +609,17 @@ performance-benchmark: - yarn - yarn test:performance +api-performance-benchmark: + stage: task + extends: + - .base-configuration + only: + variables: + - $TARGET_TASK_NAME == "performance-benchmark-scheduled" + script: + - yarn + - node ./scripts/api-performance/index.ts + ######################################################################################################################## # Check expired telemetry ######################################################################################################################## diff --git a/scripts/api-performance/index.ts b/scripts/api-performance/index.ts new file mode 100644 index 0000000000..124a9c3a85 --- /dev/null +++ b/scripts/api-performance/index.ts @@ -0,0 +1,11 @@ +import { printLog, runMain } from '../lib/executionUtils.ts' +import { runCpuPerformanceTest } from './lib/cpuPerformance.ts' +import { runMemoryPerformanceTest } from './lib/memoryPerformance.ts' + +runMain(async () => { + printLog('CPU performance...') + await runCpuPerformanceTest() + + printLog('Memory performance...') + await runMemoryPerformanceTest() +}) diff --git a/scripts/performance/lib/constants.ts b/scripts/api-performance/lib/constants.ts similarity index 100% rename from scripts/performance/lib/constants.ts rename to scripts/api-performance/lib/constants.ts diff --git a/scripts/api-performance/lib/cpuPerformance.ts b/scripts/api-performance/lib/cpuPerformance.ts new file mode 100644 index 0000000000..d112e57b57 --- /dev/null +++ b/scripts/api-performance/lib/cpuPerformance.ts @@ -0,0 +1,105 @@ +import { fetchHandlingError, timeout } from '../../lib/executionUtils.ts' +import { getOrg2ApiKey, getOrg2AppKey } from '../../lib/secrets.ts' +import { TESTS } from './constants.ts' + +// The synthetic test itself reports per-API CPU metrics to Datadog (one metric per +// button on the playground page). This script triggers the run, waits for completion, +// then queries the just-reported metrics back so we can surface them in the CI log. +const API_KEY = getOrg2ApiKey() +const APP_KEY = getOrg2AppKey() +const TIMEOUT_IN_MS = 15000 +const TEST_PUBLIC_ID = 'vcg-7rk-5av' +const RETRIES_NUMBER = 6 +const ONE_DAY_IN_SECOND = 24 * 60 * 60 + +interface SyntheticsTestResult { + results: Array<{ result_id: string }> +} + +interface SyntheticsTestStatus { + length: number + status?: number +} + +interface DatadogResponse { + series?: Array<{ pointlist?: Array<[number, number]> }> +} + +export async function runCpuPerformanceTest(): Promise { + const commitSha = process.env.CI_COMMIT_SHORT_SHA || '' + const resultId = await triggerSyntheticsTest(commitSha) + await waitForSyntheticsTestToFinish(resultId, RETRIES_NUMBER) + + const rows = await Promise.all( + TESTS.map(async (test) => { + const value = await fetchCpuMetric(test.property, commitSha) + return { 'Action Name': test.name, 'CPU Time (ms)': value ?? 'N/A' } + }) + ) + console.log('CPU Performance:') + console.table(rows) +} + +async function fetchCpuMetric(name: string, commitId: string): Promise { + const now = Math.floor(Date.now() / 1000) + const from = now - 30 * ONE_DAY_IN_SECOND + const query = `avg:cpu.sdk.${name}.performance.average{commitid:${commitId}}&from=${from}&to=${now}` + const response = await fetchHandlingError(`https://api.datadoghq.com/api/v1/query?query=${query}`, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'DD-API-KEY': API_KEY, + 'DD-APPLICATION-KEY': APP_KEY, + }, + }) + const data = (await response.json()) as DatadogResponse + const point = data.series?.[0]?.pointlist?.[0] + return point?.[1] +} + +async function triggerSyntheticsTest(commitId: string): Promise { + const body = { + tests: [ + { + public_id: TEST_PUBLIC_ID, + startUrl: `https://datadoghq.dev/browser-sdk-test-playground/performance/cpu?commitId=${commitId}`, + }, + ], + } + const response = await fetchHandlingError('https://api.datadoghq.com/api/v1/synthetics/tests/trigger/ci', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'DD-API-KEY': API_KEY, + 'DD-APPLICATION-KEY': APP_KEY, + }, + body: JSON.stringify(body), + }) + const data = (await response.json()) as SyntheticsTestResult + return data.results[0].result_id +} + +async function waitForSyntheticsTestToFinish(resultId: string, retriesNumber: number): Promise { + const url = `https://api.datadoghq.com/api/v1/synthetics/tests/${TEST_PUBLIC_ID}/results/${resultId}` + for (let i = 0; i < retriesNumber; i++) { + const response = await fetch(url, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + 'DD-API-KEY': API_KEY, + 'DD-APPLICATION-KEY': APP_KEY, + }, + }) + // do not use response.ok as we can have 404 responses + if (response.status >= 500) { + throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`) + } + const data = (await response.json()) as SyntheticsTestStatus + if (data.length !== 0 && data.status === 0) { + await timeout(TIMEOUT_IN_MS) // Wait for logs ingestion + return + } + await timeout(TIMEOUT_IN_MS) + } + throw new Error('Synthetics test did not finish within the specified number of retries') +} diff --git a/scripts/api-performance/lib/memoryPerformance.ts b/scripts/api-performance/lib/memoryPerformance.ts new file mode 100644 index 0000000000..7015e8ab4b --- /dev/null +++ b/scripts/api-performance/lib/memoryPerformance.ts @@ -0,0 +1,128 @@ +import type { Browser, CDPSession, Page, Protocol } from 'puppeteer' +import { launch } from 'puppeteer' +import { formatSize, printLog } from '../../lib/executionUtils.ts' +import { reportToDatadog } from '../../lib/reportToDatadog.ts' +import type { Test } from './constants.ts' +import { TESTS } from './constants.ts' + +const NUMBER_OF_RUNS = 30 // Rule of thumb: this should be enough to get a good average +const BATCH_SIZE = 2 + +interface MemoryResult { + name: string + value: number +} + +export async function runMemoryPerformanceTest(): Promise { + const results = await computeMemoryPerformance() + + console.log('Memory Performance:') + console.table( + results.map(({ name, value }) => ({ + 'Action Name': TESTS.find((test) => test.property === name)?.name ?? name, + 'Memory Consumption': formatSize(value), + })) + ) + + await reportToDatadog({ + message: 'Browser SDK memory consumption', + ...Object.fromEntries(results.map(({ name, value }) => [name, { memory_bytes: value }])), + }) +} + +async function computeMemoryPerformance(): Promise { + const results: MemoryResult[] = [] + const benchmarkUrl = 'https://datadoghq.dev/browser-sdk-test-playground/performance/memory' + + for (let i = 0; i < TESTS.length; i += BATCH_SIZE) { + await runTests(TESTS.slice(i, i + BATCH_SIZE), benchmarkUrl, (result) => results.push(result)) + } + + return results +} + +async function runTests(tests: Test[], benchmarkUrl: string, cb: (result: MemoryResult) => void): Promise { + await Promise.all( + tests.map(async (test) => { + const allBytesMeasurements: number[] = [] + printLog(`Running test for: ${test.button}`) + for (let j = 0; j < NUMBER_OF_RUNS; j++) { + const bytes = await runTest(test.button, benchmarkUrl) + allBytesMeasurements.push(bytes) + } + const sdkMemoryBytes = average(allBytesMeasurements) + printLog(`Average memory used by SDK for ${test.name} over ${NUMBER_OF_RUNS} runs: ${sdkMemoryBytes} bytes`) + cb({ name: test.property, value: sdkMemoryBytes }) + }) + ) +} + +async function runTest(testButton: string, benchmarkUrl: string): Promise { + const browser: Browser = await launch({ + channel: 'chrome', + args: ['--no-sandbox', '--disable-setuid-sandbox'], + }) + const page: Page = await browser.newPage() + await page.goto(benchmarkUrl) + + // Start the Chrome DevTools Protocol session and enable the heap profiler + const client: CDPSession = await page.target().createCDPSession() + await client.send('HeapProfiler.enable') + + // Select the button to trigger the test + await page.waitForSelector(testButton) + const button = await page.$(testButton) + if (!button) { + throw new Error(`Button ${testButton} not found`) + } + + await client.send('HeapProfiler.collectGarbage') + await client.send('HeapProfiler.startSampling', { samplingInterval: 50 }) + + await button.click() + const { profile } = await client.send('HeapProfiler.stopSampling') + + const measurementsBytes: number[] = [] + const sizeForNodeId = new Map() + + for (const sample of profile.samples) { + sizeForNodeId.set(sample.nodeId, (sizeForNodeId.get(sample.nodeId) || 0) + sample.size) + let sdkConsumption = 0 + for (const node of children(profile.head)) { + const consumption = sizeForNodeId.get(node.id) || 0 + if (isSdkBundleUrl(node.callFrame.url)) { + sdkConsumption += consumption + } + } + measurementsBytes.push(sdkConsumption) + } + + const medianBytes = median(measurementsBytes) + await browser.close() + return medianBytes +} + +function* children( + node: Protocol.HeapProfiler.SamplingHeapProfileNode +): Generator { + yield node + for (const child of node.children || []) { + yield* children(child) + } +} + +function isSdkBundleUrl(url: string): boolean { + return ( + url.startsWith('https://www.datad0g-browser-agent.com/') || + url.startsWith('https://www.datadoghq-browser-agent.com/') + ) +} + +function average(values: number[]): number { + return Number((values.reduce((a, b) => a + b, 0) / values.length).toFixed(2)) +} + +function median(values: number[]): number { + values.sort((a, b) => a - b) + return values[Math.floor(values.length / 2)] +} diff --git a/scripts/performance/lib/reportToDatadog.ts b/scripts/lib/reportToDatadog.ts similarity index 77% rename from scripts/performance/lib/reportToDatadog.ts rename to scripts/lib/reportToDatadog.ts index 1872577174..8e814fba77 100644 --- a/scripts/performance/lib/reportToDatadog.ts +++ b/scripts/lib/reportToDatadog.ts @@ -1,6 +1,6 @@ -import { fetchHandlingError } from '../../lib/executionUtils.ts' -import { getOrg2ApiKey } from '../../lib/secrets.ts' -import { browserSdkVersion } from '../../lib/browserSdkVersion.ts' +import { fetchHandlingError } from './executionUtils.ts' +import { getOrg2ApiKey } from './secrets.ts' +import { browserSdkVersion } from './browserSdkVersion.ts' export async function reportToDatadog( logData: Record> diff --git a/scripts/performance/index.ts b/scripts/performance/index.ts index a0a2ed93f5..6e29a96490 100644 --- a/scripts/performance/index.ts +++ b/scripts/performance/index.ts @@ -1,9 +1,7 @@ import { printLog, runMain } from '../lib/executionUtils.ts' import { fetchPR, LOCAL_BRANCH, getLastCommonCommit } from '../lib/gitUtils.ts' import { Pr } from './lib/reportAsAPrComment.ts' -import { computeAndReportMemoryPerformance } from './lib/memoryPerformance.ts' import { computeAndReportBundleSizes } from './lib/bundleSizes.ts' -import { computeAndReportCpuPerformance } from './lib/cpuPerformance.ts' runMain(async () => { const githubPr = await fetchPR(LOCAL_BRANCH!) @@ -18,10 +16,4 @@ runMain(async () => { printLog('Bundle sizes...') await computeAndReportBundleSizes(pr) - - printLog('Memory performance...') - await computeAndReportMemoryPerformance(pr) - - printLog('CPU performance...') - await computeAndReportCpuPerformance(pr) }) diff --git a/scripts/performance/lib/bundleSizes.ts b/scripts/performance/lib/bundleSizes.ts index 12cd1a241b..b67f971663 100644 --- a/scripts/performance/lib/bundleSizes.ts +++ b/scripts/performance/lib/bundleSizes.ts @@ -1,9 +1,9 @@ import { formatPercentage, formatSize } from '../../lib/executionUtils.ts' import { calculateBundleSizes } from '../../lib/computeBundleSize.ts' +import { reportToDatadog } from '../../lib/reportToDatadog.ts' import type { PerformanceMetric } from './fetchPerformanceMetrics.ts' import { fetchPerformanceMetrics } from './fetchPerformanceMetrics.ts' import { markdownArray, type Pr } from './reportAsAPrComment.ts' -import { reportToDatadog } from './reportToDatadog.ts' // The value is set to 5% as it's around 10 times the average value for small PRs. const SIZE_INCREASE_THRESHOLD = 5 diff --git a/scripts/performance/lib/cpuPerformance.ts b/scripts/performance/lib/cpuPerformance.ts deleted file mode 100644 index ff2f5f9471..0000000000 --- a/scripts/performance/lib/cpuPerformance.ts +++ /dev/null @@ -1,149 +0,0 @@ -import { fetchHandlingError, formatPercentage, timeout } from '../../lib/executionUtils.ts' -import { getOrg2ApiKey, getOrg2AppKey } from '../../lib/secrets.ts' -import { fetchPR, LOCAL_BRANCH } from '../../lib/gitUtils.ts' -import type { Pr } from './reportAsAPrComment.ts' -import { markdownArray } from './reportAsAPrComment.ts' -import type { PerformanceMetric } from './fetchPerformanceMetrics.ts' -import { fetchPerformanceMetrics } from './fetchPerformanceMetrics.ts' -import { TESTS } from './constants.ts' - -const API_KEY = getOrg2ApiKey() -const APP_KEY = getOrg2AppKey() -const TIMEOUT_IN_MS = 15000 -const TEST_PUBLIC_ID = 'vcg-7rk-5av' -const RETRIES_NUMBER = 6 -const LOCAL_COMMIT_SHA = process.env.CI_COMMIT_SHORT_SHA - -interface SyntheticsTestResult { - results: Array<{ - result_id: string - }> -} - -interface SyntheticsTestStatus { - length: number - status?: number -} - -export async function computeAndReportCpuPerformance(pr?: Pr) { - const localCpuPerformances = await computeCpuPerformance() - // local metrics reported directly by synthetics tests - if (!pr) { - return - } - let baseCpuPerformances: PerformanceMetric[] - try { - baseCpuPerformances = await fetchPerformanceMetrics( - 'cpu', - localCpuPerformances.map((cpuPerformance) => cpuPerformance.name), - pr.lastCommonCommit - ) - } catch (error) { - await pr.setCpuPerformance('Error fetching base CPU performance') - throw error - } - - await pr.setCpuPerformance( - formatCpuPerformance({ - baseCpuPerformances, - localCpuPerformances, - }) - ) -} - -async function computeCpuPerformance(): Promise { - const pr = LOCAL_BRANCH ? await fetchPR(LOCAL_BRANCH) : null - const commitSha = LOCAL_COMMIT_SHA || '' - const resultId = pr - ? await triggerSyntheticsTest(pr.number.toString(), commitSha) - : await triggerSyntheticsTest('', commitSha) - await waitForSyntheticsTestToFinish(resultId, RETRIES_NUMBER) - return fetchPerformanceMetrics( - 'cpu', - TESTS.map((test) => test.property), - LOCAL_COMMIT_SHA || '' - ) -} - -async function triggerSyntheticsTest(prNumber: string, commitId: string): Promise { - const body = { - tests: [ - { - public_id: `${TEST_PUBLIC_ID}`, - startUrl: `https://datadoghq.dev/browser-sdk-test-playground/performance/cpu?prNumber=${prNumber}&commitId=${commitId}`, - }, - ], - } - const url = 'https://api.datadoghq.com/api/v1/synthetics/tests/trigger/ci' - const response = await fetchHandlingError(url, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - 'DD-API-KEY': API_KEY, - 'DD-APPLICATION-KEY': APP_KEY, - }, - body: JSON.stringify(body), - }) - const data = (await response.json()) as SyntheticsTestResult - return data.results[0].result_id -} - -async function waitForSyntheticsTestToFinish(resultId: string, retriesNumber: number): Promise { - const url = `https://api.datadoghq.com/api/v1/synthetics/tests/${TEST_PUBLIC_ID}/results/${resultId}` - for (let i = 0; i < retriesNumber; i++) { - const response = await fetch(url, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - 'DD-API-KEY': API_KEY, - 'DD-APPLICATION-KEY': APP_KEY, - }, - }) - // do not use response.ok as we can have 404 responses - if (response.status >= 500) { - throw new Error(`HTTP Error Response: ${response.status} ${response.statusText}`) - } - const data = (await response.json()) as SyntheticsTestStatus - if (data.length !== 0 && data.status === 0) { - await timeout(TIMEOUT_IN_MS) // Wait for logs ingestion - return - } - await timeout(TIMEOUT_IN_MS) - } - throw new Error('Synthetics test did not finish within the specified number of retries') -} - -function formatCpuPerformance({ - baseCpuPerformances, - localCpuPerformances, -}: { - baseCpuPerformances: PerformanceMetric[] - localCpuPerformances: PerformanceMetric[] -}) { - return markdownArray({ - headers: [ - { label: 'Action Name', align: 'left' }, - { label: 'Base CPU Time (ms)', align: 'right' }, - { label: 'Local CPU Time (ms)', align: 'right' }, - { label: '𝚫%', align: 'right' }, - ], - rows: localCpuPerformances.map((localCpuPerformance) => { - const baseCpuPerformance = baseCpuPerformances.find( - (baseCpuPerformance) => baseCpuPerformance.name === localCpuPerformance.name - ) - - if (!baseCpuPerformance) { - return [localCpuPerformance.name, 'N/A', String(localCpuPerformance.value), 'N/A'] - } - - return [ - TESTS.find((test) => test.property === localCpuPerformance.name)!.name, - String(baseCpuPerformance.value), - String(localCpuPerformance.value), - formatPercentage((localCpuPerformance.value - baseCpuPerformance.value) / baseCpuPerformance.value, { - includeSign: true, - }), - ] - }), - }) -} diff --git a/scripts/performance/lib/memoryPerformance.ts b/scripts/performance/lib/memoryPerformance.ts deleted file mode 100644 index ed7ee8fe94..0000000000 --- a/scripts/performance/lib/memoryPerformance.ts +++ /dev/null @@ -1,198 +0,0 @@ -import type { Browser, CDPSession, Page, Protocol } from 'puppeteer' -import { launch } from 'puppeteer' -import { fetchPR, LOCAL_BRANCH } from '../../lib/gitUtils.ts' -import { formatSize, printLog } from '../../lib/executionUtils.ts' -import { markdownArray, type Pr } from './reportAsAPrComment.ts' -import type { Test } from './constants.ts' -import { TESTS } from './constants.ts' -import type { PerformanceMetric } from './fetchPerformanceMetrics.ts' -import { fetchPerformanceMetrics } from './fetchPerformanceMetrics.ts' -import { reportToDatadog } from './reportToDatadog.ts' - -const NUMBER_OF_RUNS = 30 // Rule of thumb: this should be enough to get a good average -const BATCH_SIZE = 2 - -interface TestRunResult { - medianPercentage: number - medianBytes: number -} - -export async function computeAndReportMemoryPerformance(pr?: Pr) { - const localMemoryPerformances = await computeMemoryPerformance() - await reportToDatadog({ - message: 'Browser SDK memory consumption', - ...Object.fromEntries(localMemoryPerformances.map(({ name, value }) => [name, { memory_bytes: value }])), - }) - if (!pr) { - return - } - let baseMemoryPerformances: PerformanceMetric[] - try { - baseMemoryPerformances = await fetchPerformanceMetrics( - 'memory', - localMemoryPerformances.map((memoryPerformance) => memoryPerformance.name), - pr.lastCommonCommit - ) - } catch (error) { - await pr.setMemoryPerformance('Error fetching base memory performance') - throw error - } - - await pr.setMemoryPerformance( - formatMemoryPerformance({ - baseMemoryPerformances, - localMemoryPerformances, - }) - ) -} - -export async function computeMemoryPerformance(): Promise { - const results: PerformanceMetric[] = [] - const pr = LOCAL_BRANCH ? await fetchPR(LOCAL_BRANCH) : null - const benchmarkUrl = pr - ? `https://datadoghq.dev/browser-sdk-test-playground/performance/memory?prNumber=${pr.number}` - : 'https://datadoghq.dev/browser-sdk-test-playground/performance/memory' - - for (let i = 0; i < TESTS.length; i += BATCH_SIZE) { - await runTests(TESTS.slice(i, i + BATCH_SIZE), benchmarkUrl, (result) => results.push(result)) - } - - return results -} - -async function runTests(tests: Test[], benchmarkUrl: string, cb: (result: PerformanceMetric) => void): Promise { - await Promise.all( - tests.map(async (test) => { - const testName = test.name - const testButton = test.button - const allBytesMeasurements: number[] = [] - const allPercentageMeasurements: number[] = [] - printLog(`Running test for: ${testButton}`) - for (let j = 0; j < NUMBER_OF_RUNS; j++) { - const { medianPercentage, medianBytes } = await runTest(testButton, benchmarkUrl) - allPercentageMeasurements.push(medianPercentage) - allBytesMeasurements.push(medianBytes) - } - const sdkMemoryPercentage = average(allPercentageMeasurements) - const sdkMemoryBytes = average(allBytesMeasurements) - printLog( - `Average percentage of memory used by SDK for ${testName} over ${NUMBER_OF_RUNS} runs: ${sdkMemoryPercentage}% for ${sdkMemoryBytes} bytes` - ) - cb({ name: test.property, value: sdkMemoryBytes }) - }) - ) -} - -async function runTest(testButton: string, benchmarkUrl: string): Promise { - const browser: Browser = await launch({ - channel: 'chrome', - args: ['--no-sandbox', '--disable-setuid-sandbox'], - }) - const page: Page = await browser.newPage() - await page.goto(benchmarkUrl) - - // Start the Chrome DevTools Protocol session and enable the heap profiler - const client: CDPSession = await page.target().createCDPSession() - await client.send('HeapProfiler.enable') - - // Select the button to trigger the test - await page.waitForSelector(testButton) - const button = await page.$(testButton) - if (!button) { - throw new Error(`Button ${testButton} not found`) - } - - await client.send('HeapProfiler.collectGarbage') - - // Start the heap profiler sampling - await client.send('HeapProfiler.startSampling', { - samplingInterval: 50, - }) - - await button.click() - const { profile } = await client.send('HeapProfiler.stopSampling') - const measurementsPercentage: number[] = [] - const measurementsBytes: number[] = [] - const sizeForNodeId = new Map() - - for (const sample of profile.samples) { - sizeForNodeId.set(sample.nodeId, (sizeForNodeId.get(sample.nodeId) || 0) + sample.size) - let totalSize = 0 - let sdkConsumption = 0 - for (const node of children(profile.head)) { - const consumption = sizeForNodeId.get(node.id) || 0 - totalSize += consumption - if (isSdkBundleUrl(node.callFrame.url)) { - sdkConsumption += consumption - } - } - const sdkPercentage = (sdkConsumption / totalSize) * 100 - measurementsBytes.push(sdkConsumption) - measurementsPercentage.push(sdkPercentage) - } - - const medianPercentage = median(measurementsPercentage) - const medianBytes = median(measurementsBytes) - await browser.close() - return { medianPercentage, medianBytes } -} - -function* children( - node: Protocol.HeapProfiler.SamplingHeapProfileNode -): Generator { - yield node - for (const child of node.children || []) { - yield* children(child) - } -} - -function isSdkBundleUrl(url: string): boolean { - return ( - url.startsWith('https://www.datad0g-browser-agent.com/') || - url.startsWith('https://www.datadoghq-browser-agent.com/') - ) -} - -function average(values: number[]): number { - return Number((values.reduce((a, b) => a + b, 0) / values.length).toFixed(2)) -} - -function median(values: number[]): number { - values.sort((a, b) => a - b) - return values[Math.floor(values.length / 2)] -} - -function formatMemoryPerformance({ - baseMemoryPerformances, - localMemoryPerformances, -}: { - baseMemoryPerformances: PerformanceMetric[] - localMemoryPerformances: PerformanceMetric[] -}) { - return markdownArray({ - headers: [ - { label: 'Action Name', align: 'left' }, - { label: 'Base Memory Consumption', align: 'right' }, - { label: 'Local Memory Consumption', align: 'right' }, - { label: '𝚫', align: 'right' }, - ], - rows: localMemoryPerformances.map((localMemoryPerformance) => { - const baseMemoryPerformance = baseMemoryPerformances.find( - (baseMemoryPerformance) => baseMemoryPerformance.name === localMemoryPerformance.name - ) - - if (!baseMemoryPerformance) { - return [localMemoryPerformance.name, 'N/A', formatSize(localMemoryPerformance.value), 'N/A'] - } - - return [ - TESTS.find((test) => test.property === localMemoryPerformance.name)!.name, - formatSize(baseMemoryPerformance.value), - formatSize(localMemoryPerformance.value), - formatSize(localMemoryPerformance.value - baseMemoryPerformance.value, { - includeSign: true, - }), - ] - }), - }) -} diff --git a/scripts/performance/lib/reportAsAPrComment.spec.ts b/scripts/performance/lib/reportAsAPrComment.spec.ts index 373e085337..fe6f6aa12c 100644 --- a/scripts/performance/lib/reportAsAPrComment.spec.ts +++ b/scripts/performance/lib/reportAsAPrComment.spec.ts @@ -28,20 +28,6 @@ describe('PrComment', () => { ` RUM: 10KB -
-🚀 CPU Performance - -Pending... - -
- -
-🧠 Memory Performance - -Pending... - -
- 🔗 [RealWorld](https://datadoghq.dev/browser-sdk-test-playground/realworld-scenario/?prNumber=123) ` ) diff --git a/scripts/performance/lib/reportAsAPrComment.ts b/scripts/performance/lib/reportAsAPrComment.ts index 152db75e24..e31db0dc20 100644 --- a/scripts/performance/lib/reportAsAPrComment.ts +++ b/scripts/performance/lib/reportAsAPrComment.ts @@ -8,8 +8,6 @@ export class Pr { prNumber: number lastCommonCommit: string bundleSizesSection: string = 'Pending...' - memoryPerformanceSection: string = 'Pending...' - cpuPerformanceSection: string = 'Pending...' constructor(prNumber: number, lastCommonCommit: string) { this.prNumber = prNumber @@ -21,34 +19,10 @@ export class Pr { await this.updateComment() } - async setMemoryPerformance(newSection: string) { - this.memoryPerformanceSection = newSection - await this.updateComment() - } - - async setCpuPerformance(newSection: string) { - this.cpuPerformanceSection = newSection - await this.updateComment() - } - formatComment() { return ` ${this.bundleSizesSection} -
-🚀 CPU Performance - -${this.cpuPerformanceSection} - -
- -
-🧠 Memory Performance - -${this.memoryPerformanceSection} - -
- 🔗 [RealWorld](https://datadoghq.dev/browser-sdk-test-playground/realworld-scenario/?prNumber=${this.prNumber}) ` }