Skip to content
Draft
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
24 changes: 24 additions & 0 deletions scripts/build-node-tools.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,33 @@ const profilerEditConfig = {
outfile: 'node-tools-dist/profiler-edit.js',
};

const analyzeBenchmarkConfig = {
...nodeBaseConfig,
entryPoints: ['src/node-tools/analyze-benchmark.ts'],
outfile: 'node-tools-dist/analyze-benchmark.js',
};

const extractBenchmarkStatsConfig = {
...nodeBaseConfig,
entryPoints: ['src/node-tools/extract-benchmark-stats.ts'],
outfile: 'node-tools-dist/extract-benchmark-stats.js',
};

const compareBenchmarkStatsConfig = {
...nodeBaseConfig,
entryPoints: ['src/node-tools/compare-benchmark-stats.ts'],
outfile: 'node-tools-dist/compare-benchmark-stats.js',
};

async function build() {
await esbuild.build(profilerEditConfig);
console.log('✅ profiler-edit build completed');
await esbuild.build(analyzeBenchmarkConfig);
console.log('✅ analyze-benchmark build completed');
await esbuild.build(extractBenchmarkStatsConfig);
console.log('✅ extract-benchmark-stats build completed');
await esbuild.build(compareBenchmarkStatsConfig);
console.log('✅ compare-benchmark-stats build completed');
}

build().catch(console.error);
24 changes: 24 additions & 0 deletions scripts/generate-known-functions-toml.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { execSync } from 'child_process';
import { writeFileSync } from 'fs';

const jsCode = execSync(
'node_modules/.bin/esbuild src/node-tools/profile-insert-labels/known-functions.ts --platform=node --format=esm'
).toString();

const dataUrl = 'data:text/javascript,' + encodeURIComponent(jsCode);
const { BREAK_OUT_BUCKETS } = await import(dataUrl);

let toml = '';
for (const bucket of BREAK_OUT_BUCKETS) {
toml += `[[buckets]]\n`;
toml += `name = ${JSON.stringify(bucket.name)}\n`;
toml += `funcPrefixes = [\n`;
for (const prefix of bucket.funcPrefixes) {
toml += ` ${JSON.stringify(prefix)},\n`;
}
toml += `]\n\n`;
}

const outPath = 'src/node-tools/profile-insert-labels/known-functions.toml';
writeFileSync(outPath, toml.trimEnd() + '\n');
console.log(`Wrote ${outPath}`);
7 changes: 7 additions & 0 deletions src/actions/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export function changeProfilesToCompare(profiles: string[]): Action {
};
}

export function changeProfilesToCompareBenchmark(profiles: string[]): Action {
return {
type: 'CHANGE_PROFILES_TO_COMPARE_BENCHMARK',
profiles,
};
}

export function startFetchingProfiles(): Action {
return { type: 'START_FETCHING_PROFILES' };
}
Expand Down
3 changes: 2 additions & 1 deletion src/actions/receive-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ export function viewProfileFromPostMessage(
// Given a profile view URL, extract the raw URL needed to fetch the profile
// data. This mirrors the manual pathname splitting done in retrieveProfileForRawUrl,
// so we can fetch the profile before calling stateFromLocation.
function getProfileFetchUrl(urlString: string): string {
export function getProfileFetchUrl(urlString: string): string {
const pathParts = new URL(urlString).pathname.split('/').filter((d) => d);
const dataSource = ensureIsValidDataSource(pathParts[0]);
switch (dataSource) {
Expand Down Expand Up @@ -1459,6 +1459,7 @@ export function retrieveProfileForRawUrl(
case 'uploaded-recordings':
case 'none':
case 'local':
case 'compare-benchmark':
// There is no profile to download for these datasources.
break;
default:
Expand Down
11 changes: 11 additions & 0 deletions src/app-logic/url-handling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ function getPathParts(urlState: UrlState): string[] {
return ['compare'];
}
return ['compare', urlState.selectedTab];
case 'compare-benchmark':
return ['compare-benchmark'];
case 'uploaded-recordings':
return ['uploaded-recordings'];
case 'from-browser':
Expand Down Expand Up @@ -267,6 +269,14 @@ export function getQueryStringFromUrlState(urlState: UrlState): string {
return '';
}
break;
case 'compare-benchmark':
if (urlState.profilesToCompare === null) {
return '';
}
return queryString.stringify(
{ profiles: urlState.profilesToCompare },
{ arrayFormat: 'bracket' }
);
case 'public':
case 'local':
case 'from-browser':
Expand Down Expand Up @@ -457,6 +467,7 @@ export function ensureIsValidDataSource(
case 'public':
case 'from-url':
case 'compare':
case 'compare-benchmark':
case 'uploaded-recordings':
return coercedDataSource;
default:
Expand Down
7 changes: 7 additions & 0 deletions src/components/app/AppViewRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ProfileViewer } from './ProfileViewer';
import { ZipFileViewer } from './ZipFileViewer';
import { Home } from './Home';
import { CompareHome } from './CompareHome';
import { BenchmarkCompareViewer } from './BenchmarkCompareViewer';
import { ProfileRootMessage } from './ProfileRootMessage';
import { getView } from 'firefox-profiler/selectors/app';
import { getHasZipFile } from 'firefox-profiler/selectors/zipped-profiles';
Expand All @@ -34,6 +35,7 @@ const ERROR_MESSAGES_L10N_ID: { [key: string]: string } = Object.freeze({
public: 'AppViewRouter--error-public',
'from-url': 'AppViewRouter--error-from-url',
compare: 'AppViewRouter--error-compare',
'compare-benchmark': 'AppViewRouter--error-compare',
});

type AppViewRouterStateProps = {
Expand Down Expand Up @@ -61,6 +63,11 @@ class AppViewRouterImpl extends PureComponent<AppViewRouterProps> {
return <CompareHome />;
}
break;
case 'compare-benchmark':
if (profilesToCompare === null) {
return <CompareHome />;
}
return <BenchmarkCompareViewer />;
case 'uploaded-recordings':
return <UploadedRecordingsHome />;
case 'from-browser':
Expand Down
Loading
Loading