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
function generateRandomString(length) {
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_#';
let result = '';
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return result;
}
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
const filters = [generateRandomString(10), generateRandomString(10), generateRandomString(10), generateRandomString(10), generateRandomString(10), generateRandomString(10), generateRandomString(10)];
function generateRandomFilters() {
return [filters[getRandomInt(filters.length)], filters[getRandomInt(filters.length)], filters[getRandomInt(filters.length)],];
}
function generateRandomArticleDetails() {
return {
id: generateRandomString(15),
url: generateRandomString(25),
thumbnail_url: generateRandomString(50),
categories: [filters[getRandomInt(filters.length)], filters[getRandomInt(filters.length)], filters[getRandomInt(filters.length)],]
};
}
function generateLocaleConfig() {
const articles = [];
for (let i = 0; i < 5000; i++) {
articles.push(generateRandomArticleDetails());
}
return {
articles,
locale: generateRandomString(5),
filters: generateRandomFilters(),
};
}
function getArticlesForFilters(filters, articles) {
return articles.filter(article => {
return article.categories.some(categoryFilter => filters.includes(categoryFilter));
});
}
const testLocale = generateLocaleConfig();
console.log('Total articles:', testLocale.articles.length);
Ready to run.
Test | Ops/sec | |
---|---|---|
# of articles matching |
| ready |
noop |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.