jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>// Lodash sortBy - use same as app, or native for comparison
function sortByLabel(arr) {
return arr.slice().sort((a, b) => (a.label || "").toLowerCase().localeCompare((b.label || "").toLowerCase()));
}
// Mock options with label (like segment filter options)
function makeOptions(n, prefix) {
const out = [];
for (let i = 0; i < n; i++) {
out.push({ value: "opt_" + i, label: (prefix || "Option ") + " " + i, category: "test" });
}
return out;
}
// formatConditionsInSubGroups - simplified (no getSurveyType/surveyResponsesRanges)
const CONDITION_LABEL = {
user_events: "Events",
product_features: "Feature Engagement",
"imported_property-company": "Company properties",
"imported_property-user": "User properties",
default_property: "Default Properties",
surveys: "Microsurvey events",
campaigns: "Tours",
lists: "Launchers",
};
function formatConditionsInSubGroups(currentConditions) {
const conditions = currentConditions.slice();
const formatedConditionsInSubGroups = [
...new Set(conditions.map((c) => `${c.category}${c.propertyType ? "-" + c.propertyType : ""}`)),
].map((condition) => {
const category = condition.split("-")[0];
const propertyType = condition.split("-")[1];
return {
label: CONDITION_LABEL[condition] || condition,
category,
propertyType,
options: [],
};
});
currentConditions.forEach((condition) => {
formatedConditionsInSubGroups.forEach((formatedCondition) => {
if (condition?.propertyType === formatedCondition.propertyType) {
formatedCondition.options.push(condition);
return;
}
if (condition.category === formatedCondition.category) {
formatedCondition.options.push(condition);
}
});
});
return formatedConditionsInSubGroups;
}
function getSortedUserEvents(newCustomEvents, userEventNames) {
const combined = [...newCustomEvents, ...userEventNames];
const seen = new Set();
const deduped = combined.filter((e) => {
if (seen.has(e.id)) return false;
seen.add(e.id);
return true;
});
const enabled = deduped.filter((e) => !e.isDisabled);
const disabled = deduped.filter((e) => !!e.isDisabled);
const byLabel = (a, b) => (a.label || "").toLowerCase().localeCompare((b.label || "").toLowerCase());
return [...enabled.sort(byLabel), ...disabled.sort(byLabel)];
}
// Data sizes similar to your screenshot (adjust as needed)
var userProperties = makeOptions(609, "User property");
var companyProperties = makeOptions(116, "Company property");
var campaigns = makeOptions(1234, "Tour");
var surveys = makeOptions(996, "Survey");
var launchers = makeOptions(676, "Launcher");
var embeds = makeOptions(965, "Embed");
var eventNames = makeOptions(143, "Event").map((o, i) => ({ ...o, id: "ev_" + i, isDisabled: i % 10 === 0 }));
var allConditions = [
...userProperties.map((o) => ({ ...o, category: "imported_property", propertyType: "user" })),
...companyProperties.map((o) => ({ ...o, category: "imported_property", propertyType: "company" })),
...campaigns.map((o) => ({ ...o, category: "campaigns" })),
...surveys.map((o) => ({ ...o, category: "surveys" })),
...launchers.map((o) => ({ ...o, category: "lists" })),
];Ready to run.
| Test | Ops/sec | |
|---|---|---|
| Test case 1: sortBy userProperties (609 items) | | ready |
| Test case 2: sortBy campaigns (1234 items) | | ready |
| Test case 3: formatConditionsInSubGroups (full mixed list) | | ready |
| Test case 4: getSortedUserEvents (event names) | | ready |
| Test case 5: sortBy all categories (combined cost) | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.