Skip to content

Instantly share code, notes, and snippets.

@manciuszz
Last active April 3, 2025 20:08
Show Gist options
  • Save manciuszz/477a8924f319d2f78e10223ca2cee0f9 to your computer and use it in GitHub Desktop.
Save manciuszz/477a8924f319d2f78e10223ca2cee0f9 to your computer and use it in GitHub Desktop.
A simple script to fetch the 'leaderboards' from Geekbench using JavaScript
{
const PARAMETERS = {
OS: "Windows",
CPU: "10875H"
};
const getScores = function(page) {
return Array.from(page.querySelectorAll('.list-col-inner > .row')).map((row) => {
const model = row.querySelector('.list-col-model').innerText;
const scores = Array.from(row.querySelectorAll('.list-col-text-score')).map((score) => parseInt(score.textContent));
const singleCore = scores[0];
const multiCore = scores[1];
return {model, singleCore, multiCore};
});
};
const getTotalPages = (function() {
const domParser = new DOMParser();
return async function(cpuModel, operatingSystem) {
const document = await fetch(`https://browser.geekbench.com/search?q=${cpuModel}+${operatingSystem}`).then((response) => response.text()).then((html) => domParser.parseFromString(html, "text/html"));
return parseInt(Array.from(document.querySelectorAll(".page-item:not(.next) > a")).at(-1).textContent);
};
})();
const generatePages = (function() {
const domParser = new DOMParser();
return async function(pageNumber, cpuModel, operatingSystem) {
const document = await fetch(`https://browser.geekbench.com/search?k=v6_cpu&page=${pageNumber}&q=${cpuModel}+${operatingSystem}`).then((response) => response.text()).then((html) => domParser.parseFromString(html, "text/html"));
return getScores(document);
};
})();
const computeBestScores = function(scores, n = 3) {
const bestSingleCore = scores.sort((a, b) => b.singleCore - a.singleCore).slice(0, n);
const bestMultiCore = scores.sort((a, b) => b.multiCore - a.multiCore).slice(0, n);
const bestOverall = scores.sort((a, b) => (b.singleCore - a.singleCore) + (b.multiCore - a.multiCore)).slice(0, n);
console.log(`Raw Scores: ${scores}`, `Best Overall Scores: ${bestOverall}`, `Best Single Core Scores: ${bestSingleCore}`, `Best Multi Core Scores: ${bestMultiCore}`);
};
(async function() {
const scores = [];
const totalPages = await getTotalPages(PARAMETERS.CPU, PARAMETERS.OS);
for(let pageNum=1; pageNum <= totalPages; pageNum++) {
scores.push(await generatePages(pageNum, PARAMETERS.CPU, PARAMETERS.OS));
}
computeBestScores(scores.flat());
})();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment