{"id":13526476,"url":"https://github.com/logicalparadox/matcha","last_synced_at":"2025-04-08T09:11:43.832Z","repository":{"id":1983392,"uuid":"2915220","full_name":"logicalparadox/matcha","owner":"logicalparadox","description":"A caffeine driven, simplistic approach to benchmarking.","archived":false,"fork":false,"pushed_at":"2020-09-04T21:26:52.000Z","size":102,"stargazers_count":563,"open_issues_count":17,"forks_count":38,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-01T08:38:05.859Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/logicalparadox.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-05T08:35:33.000Z","updated_at":"2025-03-26T02:54:46.000Z","dependencies_parsed_at":"2022-09-09T15:00:57.911Z","dependency_job_id":null,"html_url":"https://github.com/logicalparadox/matcha","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logicalparadox%2Fmatcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logicalparadox%2Fmatcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logicalparadox%2Fmatcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logicalparadox%2Fmatcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/logicalparadox","download_url":"https://codeload.github.com/logicalparadox/matcha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485185,"owners_count":20946395,"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":[],"created_at":"2024-08-01T06:01:30.308Z","updated_at":"2025-04-08T09:11:43.796Z","avatar_url":"https://github.com/logicalparadox.png","language":"JavaScript","readme":"# Matcha\n\n\u003e A caffeine driven, simple approach to benchmarking.\n\nMatcha allow you to design experiments that will measure the performance of your code. It is recommended that each\nbench focus on a specific point of impact in your application.\n\n![Matcha Report](http://f.cl.ly/items/3X0a1m0S250t2A0W3n1r/matcha-benchmark.png)\n\n## Installation\n\nMatcha is available on npm.\n\n      $ npm install matcha\n\n## Writing Async Benchmarks\n\nThough suites/benches are executed serially, the benches themselves can be asyncronous. Furthermore, suites ran with\nthe matcha command line runner have a number of globals to simplify bench definitions. Take the following code, for example:\n\n```js\nsuite('Make Tea', function () {\n  var tea = new CupOfTea('green');\n\n  bench('boil water', function(next) {\n    tea.boil('85℃', function (err, h20) {\n      // perfect temperature!\n      next();\n    });\n  });\n\n  // add tea, pour, ...  \n\n  bench('sip tea', function() {\n    tea.sip('mmmm');\n  });\n});\n```\n#### Async vs. Sync\n\nSince boiling water takes time, a `next` function was provided to each iteration in our bench to be called when the\nasync function completes. Since the consumption of tea provides instant gratification, no `next` needed to be provided, even though\nwe still wish to measure it.\n\n#### Setup/Teardown\n\nArbitray functions may be specified for setup or teardown for each suite by using the `before` and `after` keywords.\nThese function may be sync or async.\n\n```js\nsuite('DB', function() {\n  before(function(next) {\n    db.connect('localhost:9090', next);\n  });\n\n  bench(function(next) {\n    // ...\n  });\n\n  after(function() {\n    db.close();\n  });\n});\n```\n\n#### Setting Options\n\nAs not all code is equal, we need a way to change the running conditions for our benches. Options can currently be changed for\nany given suite, and will be retained for any nested suites or benches of that suite. \n\nTo set an option:\n\n```js\nsuite('Make Tea', function () {\n  set('iterations', 10000);\n  set('type', 'static');\n  // ...\n```\n##### Defaults\n\nHere are all available options and the default values:\n\n```js\nset('iterations', 100);     // the number of times to run a given bench\nset('concurrency', 1);      // the number of how many times a given bench is run concurrently\nset('type', 'adaptive');    // or 'static' (see below)\nset('mintime', 500);        // when adaptive, the minimum time in ms a bench should run\nset('delay', 100);          // time in ms between each bench\n```\n\n##### Static vs Adaptive\n\nThere are two modes for running your benches: 'static' and 'adaptive'. Static mode will run exactly the set number of iterations.\nAdaptive will run the set iterations, then if a minimal time elapsed has not passed, will run more another set of iterations, then\ncheck again (and repeat) until the requirement has been satisfied.\n\n## Running Benchmarks\n\nRunning of your benchmarks is provided through `./bin/matcha`. The recommended approach is to add a devDependancy in your\n`package.json` and then add a line to a `Makefile` or build tool. The `matcha` bin will accept a list of files to load or will \nlook in the current working directory for a folder named `benchmark` and load all files.\n\n      $ matcha suite1.js suite2.js\n\n## Options\n\n        -h, --help               view matcha usage information\n        -v, --version            view matcha version\n        -R, --reporter [clean]   specify the reporter to use\n        -I, --interface [bdd]    specify the interface to expect\n        --interfaces             display available interfaces\n        --reporters              display available reporters\n\n#### -I, --interface \u003cname\u003e\nThe --interface option lets you specify the interface to use, defaulting to \"bdd\".\n\n#### -R, --reporter \u003cname\u003e\nThe --reporter option allows you to specify the reporter that will be used, defaulting to \"clean\".\n\n### Interfaces\nMatcha \"interface\" system allows developers to choose their style of DSL. Shipping with bdd, and     exports flavoured interfaces.\n#### bdd\n\n```js\nsuite('suite name', function(){\n    set('iterations', 10);\n    bench('bench name', function(done){\n        some_fn(done);\n  });\n});\n```\n\n#### exports\n\n```js\nexports['suite name'] = {\n    options: {\n      iterations: 10\n    },\n    bench: {\n        'bench name': function (doen) {\n            some_fn(done);\n        }\n    }\n};\n```\n\n### Reporters\nMatcha reporters adjust to the terminal window.\n#### clean\nGood-looking default reporter with colors on the terminal screen.\n#### plain\nSimilar to _clean_ reporter but without colors and other ANSI sequences.\n#### csv\nCompletely different, create csv formated rows for later processing.\n\n## Contributing\n\nInterested in contributing? Fork to get started. Contact [@logicalparadox](http://github.com/logicalparadox) \nif you are interested in being regular contributor.\n\n##### Contibutors \n\n* Jake Luer ([Github: @logicalparadox](http://github.com/logicalparadox)) ([Twitter: @jakeluer](http://twitter.com/jakeluer)) ([Website](http://alogicalparadox.com))\n* Patrick Steele-Idem ([Github: @patrick-steele-idem](http://github.com/patrick-steele-idem)) ([Twitter: @psteeleidem](http://twitter.com/psteeleidem))\n\n## Shoutouts\n\n* [mocha](https://mochajs.org) inspired the suite/bench definition language. \n\n## License\n\n(The MIT License)\n\nCopyright (c) 2011-2012 Jake Luer \u003cjake@alogicalparadox.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","funding_links":[],"categories":["JavaScript","Repository","Packages","包","Benchmark","目录","Benchmark [🔝](#readme)","Benchmarking","Benchmark - JavaScript","基准测试","Number","Benchmark - Javascript","Github"],"sub_categories":["Testing","Benchmarking","基准化分析","Runner","基准化","Meetups","运行器","运行器e2e测试","js"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogicalparadox%2Fmatcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flogicalparadox%2Fmatcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogicalparadox%2Fmatcha/lists"}