{"id":17969,"library":"superbench","title":"Superbench Load Testing Framework","description":"Superbench is a lightweight load testing framework for Node.js, designed to handle distributed test execution and consolidate results. It enables users to define complex test scenarios directly in JavaScript, offering significant flexibility as it does not impose any specific API client dependencies, allowing it to test virtually any server. Currently at version 0.0.2, Superbench is in its early development stages, suggesting a relatively infrequent release cadence as features mature towards a stable 1.0 release. Key differentiators include its built-in support for master/slave clustering to distribute load efficiently and its focus on providing detailed performance metrics aggregated from various workers. This makes it suitable for scenarios requiring high concurrency across multiple client machines, offering a clear alternative to single-machine load testers.","status":"active","version":"0.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/superbench/superbench","tags":["javascript","typescript"],"install":[{"cmd":"npm install superbench","lang":"bash","label":"npm"},{"cmd":"yarn add superbench","lang":"bash","label":"yarn"},{"cmd":"pnpm add superbench","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Benchmark definition files are expected to be ESM modules (e.g., .mjs or 'type: module' in package.json).","wrong":"const defineBenchmark = require(\"superbench\");","symbol":"defineBenchmark","correct":"import defineBenchmark from \"superbench\";"}],"quickstart":{"code":"import defineBenchmark from \"superbench\";\n\ndefineBenchmark({\n    title: \"someAPI\",\n    description: \"check some API\",\n    concurrentRequestNum: 10,\n    measurementInterval: 30,  // sec\n    duration: 180 // sec\n}, async benchmark => {\n    // You need write a scenario code for parallelization that is run in a worker.\n    const tasks = [];\n    // superbench calculates request num of this worker.\n    // You can get it from `benchmark.requestNum`.\n    for (let i = 0; i < benchmark.requestNum; i++) {\n        tasks.push(new Promise(async resolve => {\n            // If you run loop processing, you need to check `benchmark.running`.\n            while (benchmark.running) {\n                const t1 = benchmark.test(\"healthcheck1\");\n                try {\n                    // Replace 'yourAPIClient.callSomeAPI()' with your actual API call\n                    // For demonstration, we'll simulate an async operation.\n                    await new Promise(r => setTimeout(r, Math.random() * 50 + 100)); \n                    t1.success();\n                } catch (e) {\n                    t1.error(e);\n                }\n            }\n            resolve();\n        }));\n    }\n    await Promise.all(tasks);\n});","lang":"typescript","description":"Defines a distributed load test scenario using `superbench`, including parallel tasks and performance measurement for an arbitrary API."},"warnings":[{"fix":"Refer to the official GitHub repository for the latest documentation and release notes.","message":"Superbench is in early alpha (v0.0.2). The API and internal mechanisms are subject to change in future releases, potentially introducing breaking changes without major version bumps.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Ensure your benchmark file uses `.mjs` extension or your project's `package.json` includes `\"type\": \"module\"`. Always use `import` statements.","message":"Benchmark definition files (`.js` or `.ts`) are expected to be treated as ECMAScript Modules (ESM). Using CommonJS `require()` syntax or running without `type: \"module\"` in your `package.json` for ESM files will result in errors.","severity":"gotcha","affected_versions":">=0.0.1"},{"fix":"Upgrade Superbench to version `0.0.2` or later to resolve this measurement bug.","message":"Versions prior to 0.0.2 could encounter an error if no successful requests were recorded within a `measurementInterval`, leading to test instability.","severity":"breaking","affected_versions":"<=0.0.1"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Ensure your benchmark file has a `.mjs` extension, or add `\"type\": \"module\"` to your project's `package.json`.","cause":"Your benchmark definition file is being interpreted as a CommonJS module, but it uses `import` statements.","error":"SyntaxError: Cannot use import statement outside a module"},{"fix":"Install Superbench globally using `npm install -g superbench`.","cause":"The Superbench CLI tool is not installed globally or is not in your system's PATH.","error":"superbench: command not found"},{"fix":"Upgrade Superbench to version `0.0.2` or newer (`npm update superbench`) to fix this issue. Also, ensure your test scenario is correctly designed to produce results.","cause":"This error occurs in Superbench versions <=0.0.1 when no successful test results are recorded within a specified measurement interval, which was a bug.","error":"Error: No results within measurementInterval"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}