{"id":16760262,"url":"https://github.com/ryanve/lap","last_synced_at":"2025-10-18T13:46:15.678Z","repository":{"id":14638261,"uuid":"17355888","full_name":"ryanve/lap","owner":"ryanve","description":"JavaScript performance testing library","archived":false,"fork":false,"pushed_at":"2016-12-11T02:21:31.000Z","size":32,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"gh-pages","last_synced_at":"2025-04-02T18:56:26.904Z","etag":null,"topics":["javascript","performance","timestamp"],"latest_commit_sha":null,"homepage":"https://ryanve.github.io/lap","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-MIT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-03-03T05:16:24.000Z","updated_at":"2023-08-08T21:07:20.000Z","dependencies_parsed_at":"2022-09-01T23:02:25.339Z","dependency_job_id":null,"html_url":"https://github.com/ryanve/lap","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Flap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Flap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Flap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Flap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanve","download_url":"https://codeload.github.com/ryanve/lap/tar.gz/refs/heads/gh-pages","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248262041,"owners_count":21074236,"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":["javascript","performance","timestamp"],"created_at":"2024-10-13T04:22:55.195Z","updated_at":"2025-10-18T13:46:10.659Z","avatar_url":"https://github.com/ryanve.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lap\n#### JavaScript performance testing library for the browser or server\n\n## API\n\u003ca name=\"methods-toc\"\u003e\u003c/a\u003e\n#### Methods\n\n- \u003ca href=\"#time\"\u003e\u003cb\u003elap.time\u003c/b\u003e(laps, racers)\u003c/a\u003e\n- \u003ca href=\"#speed\"\u003e\u003cb\u003elap.speed\u003c/b\u003e(laps, racers)\u003c/a\u003e\n- \u003ca href=\"#timestamp\"\u003e\u003cb\u003elap.timestamp\u003c/b\u003e()\u003c/a\u003e\n\n#### Parameters\n\n- \u003cvar\u003elaps\u003c/var\u003e refers to number of laps to run (positive integer)\n- \u003cvar\u003eracers\u003c/var\u003e refers to function(s) to race (array or single function)\n\n#### Usage tips\n\n- Use JavaScript exponential notation like `1e3` (rather than `1000`) for expressing large numbers\n- Accurate results require many \u003cvar\u003elaps\u003c/var\u003e. The ideal amount depends on how complex the racers are:\n  - `Infinity` speeds and `0` times both indicate inadequate \u003cvar\u003elaps\u003c/var\u003e\n  - Results taking too long indicates excessive \u003cvar\u003elaps\u003c/var\u003e. Use less \u003cvar\u003elaps\u003c/var\u003e \u003cb\u003eor\u003c/b\u003e use the [`.async`](#async-sync) syntax\n\n\u003ca name=\"time\"\u003e\u003c/a\u003e\n#### `lap.time(laps, racers)`\n- Time how long it takes each racer to run the given number of laps\n- \u003cb\u003e@return\u003c/b\u003e array of times measured in milliseconds\n\n##### `.time` example\n```js\nlap.time(1e5, [\n  function() { document.getElementById('example') },\n  function() { document.querySelector('#example') },\n  function() { document.querySelectorAll('#example')[0] }\n]) // =\u003e [40.000000000873115, 44.99999999825377, 116.00000000180444]\n```\n\n\u003ca name=\"speed\"\u003e\u003c/a\u003e\n#### `lap.speed(laps, racers)`\n- Estimate each racer's average speed over a course of \u003cvar\u003elaps\u003c/var\u003e\n- \u003cb\u003e@return\u003c/b\u003e array of speeds measured in operations per second\n\n##### `.speed` example\n```js\nlap.speed(1e5, [\n  function() { document.getElementById('example') },\n  function() { document.querySelector('#example') },\n  function() { document.querySelectorAll('#example')[0] }\n]) // =\u003e [2500000.0004001777, 2222222.2219491494, 884955.7522315352]\n```\n\n\u003ca name=\"timestamp\"\u003e\u003c/a\u003e\n#### `lap.timestamp()`\n- Get a hi-resolution timestamp\n- \u003cb\u003e@return\u003c/b\u003e number measured in milliseconds\n\n##### `.timestamp` example\n```js\nlap.timestamp() // =\u003e 1610.000000000582\n```\n\n\u003ca name=\"async-sync\"\u003e\u003c/a\u003e\n#### `.async`\n- [Methods](#methods-toc) are callable `.async` with the same arguments plus a `(err, result)` callback\n- \u003cb\u003e@return\u003c/b\u003e undefined\n\n##### `.async` syntax\n- `lap.time.async(laps, racers, callback)`\n- `lap.speed.async(laps, racers, callback)`\n- `lap.timestamp.async(callback)`\n\n##### `.async` example\n```js\nlap.time.async(1e5, function() {\n  [].concat([0, 1, 2, 3])\n}, function(err, result) {\n  err || console.log(result[0] + ' ms')\n}) // =\u003e undefined\n```\n\n#### `.sync`\n\n`.sync` methods are included for expressiveness but these are just aliases. `lap.time === lap.time.sync` etc.\n\n##### `.sync` example\n```js\nlap.time.sync(1e5, [\n  function() { document.getElementById('example') },\n  function() { document.querySelector('#example') },\n  function() { document.querySelectorAll('#example')[0] }\n]) // =\u003e [40.000000000873115, 45.99999999481952, 115.00000000523869]\n```\n\n## Compatibility\n\nWorks...everywhere\u003cb\u003e!\u003c/b\u003e Tested in node, Chrome, FF, Opera, IE8\n\n## Contribute\n\n\u003ca name=\"cli\"\u003e\u003c/a\u003e\n```sh\n$ npm start\n$ npm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Flap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanve%2Flap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Flap/lists"}