{"id":21800250,"url":"https://github.com/googlechromelabs/css-selector-benchmark","last_synced_at":"2025-04-13T17:41:57.454Z","repository":{"id":264986599,"uuid":"862293521","full_name":"GoogleChromeLabs/css-selector-benchmark","owner":"GoogleChromeLabs","description":"CSS Selector Benchmarks, using PerfTestRunner and Puppeteer","archived":false,"fork":false,"pushed_at":"2025-03-28T22:49:00.000Z","size":290,"stargazers_count":22,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-05T15:54:29.729Z","etag":null,"topics":["css","performance","puppeteer"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GoogleChromeLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-24T11:09:57.000Z","updated_at":"2025-02-02T22:55:51.000Z","dependencies_parsed_at":"2024-11-27T14:21:53.280Z","dependency_job_id":null,"html_url":"https://github.com/GoogleChromeLabs/css-selector-benchmark","commit_stats":null,"previous_names":["googlechromelabs/css-selector-benchmark"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fcss-selector-benchmark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fcss-selector-benchmark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fcss-selector-benchmark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GoogleChromeLabs%2Fcss-selector-benchmark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GoogleChromeLabs","download_url":"https://codeload.github.com/GoogleChromeLabs/css-selector-benchmark/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248755665,"owners_count":21156628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","performance","puppeteer"],"created_at":"2024-11-27T10:43:38.362Z","updated_at":"2025-04-13T17:41:57.433Z","avatar_url":"https://github.com/GoogleChromeLabs.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSS Selector Benchmark\n\nCSS Selector Benchmarks, using PerfTestRunner and Puppeteer\n\n## Prerequisites\n\n### Project Setup\n\nInstall dependencies\n\n```bash\nnpm i\n```\n\nInstall browsers to test with\n\n```bash\nnpx puppeteer browsers install chrome\nnpx puppeteer browsers install firefox\n```\n\n### Start the web server\n\nThe benchmarks are HTML pages which need to be served by a web server\n\n```bash\nnpm run start\n```\n\nThe Web Server is now running at http://localhost:3000/\n\n## Running a benchmark\n\nWith the Web Server running, invoke a benchmark on the CLI:\n\n```bash\nnpm run benchmark example\n```\n\nThis will run the benchmark served by `http://localhost:3000/benchmarks/example/`, whose source is located at `./src/benchmarks/example/index.html`\n\nNote: You can also run benchmarks directly in a browser. To do so, visit its URL and invoke `window.startTest().then(console.table);` on the Console.\n\n### Choosing which browser to run the benchmarks in\n\nTo select which browser to test things in, use the `--browser` option.\n\n```bash\nnpm run benchmark example -- --browser=firefox\n```\n\nSupported options:\n\n- `chrome` = Use Chrome\n  - `chrome` = Use Chrome Stable\n  - `chrome-beta` = Use Chrome Beta\n  - `chrome-dev` = Use Chrome Dev\n  - `chrome-canary` = Use Chrome Canary\n- `firefox`= Use Firefox\n\nThe default used browser is `chrome`.\n\nA note will be printed on screen to show which version you are using. For example:\n\n```\nℹ️ Running benchmark using browser firefox (firefox/129.0a1)\n```\n\n## Creating a benchmark\n\nBenchmarks are HTML pages stored in a subfolder in `./src/benchmarks/`. The page **MUST** expose a `window.startTest` method which returns a promise. When the test logic is done, it **MUST** resolve that promise.\n\nThis `window.startTest` is automatically invoked by `npm run benchmark x` when the page has loaded. Once `window.startTest` has resolved, the benchmark will be closed and any returned output will be logged.\n\nUsing [Chromium’s `PerfTestRunner`](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/third_party/blink/perf_tests/resources/runner.js), a typical test looks like this:\n\n```html\n\u003cscript type=\"module\"\u003e\nimport PerfTestRunner from '/lib/PerfTestRunner.js';\n\nwindow.startTest = () =\u003e new Promise((resolve, reject) =\u003e {\n\tPerfTestRunner.measureRunsPerSecond({\n\t\tdescription: 'This is an example benchmark',\n\t\trun: function () {\n\t\t\t// Benchmark logic here, e.g. a document.querySelectorAll call in a loop\n\t\t},\n\t\tdone: resolve,\n\t});\n});\n\u003c/script\u003e\n```\n\nNaming your benchmark `index.html` is not required, but then you need to append the filename to the invocation, e.g. `npm run benchmark dom/qsa.html`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglechromelabs%2Fcss-selector-benchmark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglechromelabs%2Fcss-selector-benchmark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglechromelabs%2Fcss-selector-benchmark/lists"}