Skip to content

Commit

Permalink
Improve developerMode updateURL (WebKit#431)
Browse files Browse the repository at this point in the history
- Simplify the tag/suite/suites selection code by always deleting all searchParams first
- Don't use tags if there is only one selected suite (previously selecting "React-Stockcharts-SVG" currently sets the "svg" tag which is a bit unexpected)
- Compare against defaultParams for "measurementMethod" using the existing method for bool values
  • Loading branch information
camillobruni authored Oct 10, 2024
1 parent 400a5b8 commit c2e8d4f
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions resources/developer-mode.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,10 @@ function updateURL() {
// to comma separate only the selected
const selectedSuites = Suites.filter((suite) => !suite.disabled);

if (!selectedSuites.length) {
url.searchParams.delete("tags");
url.searchParams.delete("suites");
url.searchParams.delete("suite");
} else {
url.searchParams.delete("tags");
url.searchParams.delete("suite");
url.searchParams.delete("tags");
url.searchParams.delete("suites");
url.searchParams.delete("suite");
if (selectedSuites.length) {
// Try finding common tags that would result in the current suite selection.
let commonTags = new Set(selectedSuites[0].tags);
for (const suite of Suites) {
Expand All @@ -255,26 +252,18 @@ function updateURL() {
else
commonTags = new Set(suite.tags.filter((tag) => commonTags.has(tag)));
}
if (commonTags.size) {
if (selectedSuites.length > 1 && commonTags.size) {
const tags = [...commonTags][0];
if (tags === "default")
url.searchParams.delete("tags");
else
if (tags !== "default")
url.searchParams.set("tags", tags);
url.searchParams.delete("suites");
} else {
url.searchParams.delete("tags");
url.searchParams.set("suites", selectedSuites.map((suite) => suite.name).join(","));
}
}

if (params.measurementMethod !== "raf")
url.searchParams.set("measurementMethod", "timer");
else
url.searchParams.delete("measurementMethod");

const boolParamKeys = ["iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync"];
for (const paramKey of boolParamKeys) {
const defaultParamKeys = ["measurementMethod", "iterationCount", "useWarmupSuite", "warmupBeforeSync", "waitBeforeSync"];
for (const paramKey of defaultParamKeys) {
if (params[paramKey] !== defaultParams[paramKey])
url.searchParams.set(paramKey, params[paramKey]);
else
Expand Down

0 comments on commit c2e8d4f

Please sign in to comment.