{"id":18832386,"url":"https://github.com/brainpoint/febs-test","last_synced_at":"2026-01-25T09:30:16.445Z","repository":{"id":57234190,"uuid":"108267777","full_name":"brainpoint/febs-test","owner":"brainpoint","description":"febs-test for server stress test","archived":false,"fork":false,"pushed_at":"2017-11-22T06:49:30.000Z","size":50,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-06T09:47:46.053Z","etag":null,"topics":["febs","server","stress","stress-simulations","stress-testing","test"],"latest_commit_sha":null,"homepage":null,"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/brainpoint.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-25T12:36:16.000Z","updated_at":"2017-10-25T12:41:30.000Z","dependencies_parsed_at":"2022-09-15T02:42:51.265Z","dependency_job_id":null,"html_url":"https://github.com/brainpoint/febs-test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainpoint%2Ffebs-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainpoint%2Ffebs-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainpoint%2Ffebs-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brainpoint%2Ffebs-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brainpoint","download_url":"https://codeload.github.com/brainpoint/febs-test/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239768935,"owners_count":19693763,"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":["febs","server","stress","stress-simulations","stress-testing","test"],"created_at":"2024-11-08T01:57:43.120Z","updated_at":"2026-01-25T09:30:16.399Z","avatar_url":"https://github.com/brainpoint.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"febs-test for server stress test;\n\n- [Install](#install)\n- [Example](#example)\n- [Interface](#interface)\n\n# Install\n\nUse npm to install:\n\n```js\nnpm install febs-test --save\n```\n\n# Example\n\n```js\n'use strict';\n/**\n* Copyright (c) 2017 Copyright brainpoint All Rights Reserved.\n* Author: lipengxiang\n* Date: \n* Desc: \n*/\n\nvar test = require('febs-test');\nvar http = require('http');\n\n//\n// test work.\nfunction test_work(){ // or async function test_work() {\n    // todo.\n    test.add_count('request', 1);\n    let token = test.begin('request nodjes');\n    http.get('http://nodejs.org/dist/index.json', (res) =\u003e {\n      const { statusCode } = res;\n      let error;\n      if (statusCode !== 200) {\n        test.end_custom(token, statusCode.toString());\n      } else {\n        test.end_success(token);\n      }\n\n      test.finish();\n    }).on('error', (e) =\u003e {\n      test.end_failure(token);\n    });\n}\n\n//\n// begin test.\ntest.start({\n            clientTotal: 100,          // 客户端总数.\n            processNum: 10,            // 进程数. 默认50个.\n            createDurtion: 5000,        // in ms, \b模拟客户端在此时间段内创建完成. 默认10000\n            testDurtion : 20000,          // in ms, 测试的持续时间.\n          }, test_work);\n```\n\nresult: \n\n```bash\n       ************************************************************\n       *      Stress test begin.\n       *        HYs-MacBook-Air.local darwin\n       *        - cpu numbers:  4\n       *        - cpu type:     undefined undefined MHz\n       *        - total memory: 4096 MB\n       *        - free memory:  191 MB\n       * ----------------------------------------------------------\n       *      config of:\n       *        - client total:                  100\n       *        - client number in per process:  10\n       *        - client create durtion:         5000 ms\n       *        - process number:                10\n       *        - test durtion:                  20 s\n       *        - logfile:\n       *        - errfile:\n       ************************************************************\n\n[start at: 2017-10-26 13:51:14]\n⠋ Testing...\n⠧ Testing... ...25%\n⠇ Testing... ...50%\n⠼ Testing...\n\n------------------------------------\n- key count                        -\n------------------------------------\n    [request]            : 100\n\n------------------------------------\n- statistics                       -\n------------------------------------\n    [request nodjes]:\n        request          : 100\n        timeout          : 0\n        success          : 100\n               delay-avg : 1944 ms\n               delay-max : 8303 ms\n               delay-min : 414 ms\n        failure          : 0\n               delay-avg : 0 ms\n               delay-max : 0 ms\n               delay-min : 0 ms\n\n[finish at: 2017-10-26 13:51:25]\nTest take 12 s\n```\n\n# Interface\n\n```js\n/**\n* @desc: \b\b\b初始化测试模块.\n* @param opt: \n*         {\n            clientTotal,          // 客户端总数.\n            processNum,           // 进程数. 默认50个.\n            createDurtion,        // in ms, \b模拟客户端在此时间段内创建完成. 默认10000\n            testDurtion,          // in ms, 测试的持续时间.\n            logfile,              // 日志文件位置. null则不会存储.\n            errfile,              // 错误日志位置. null则不会存储.\n            debug,                // \b指明debug则workCB在主线程运行, 并且不创建其他进程.\n          }\n* @param workCB: function(pid, tid) {}  // 在此回调中编写测试程序.\n* @return: \n*/\nfunction start(opt, workCB)\n```\n\n```js\n/**\n* @desc: \b\b\b退出当前测试. 如果不调用此语句, 则测试会等待testDurtion时间到达后结束.\n*/\nfunction finish()\n```\n\n```js\n/**\n  * @desc: 开始一个测试, 并在失败和成功的时候调用相应的处理.\n  *        在测试结束后, 同类的测试将会归为相同的统计.\n  *        在超时过后还未调用结束测试方法的, 将标记为超时.\n  * @param type: \b测试的类型, 相同的测试类型, 将累加统计.\n  * @return: test_token. \n  */\nfunction begin(type)\n```\n\n```js\n/**\n* @desc: 结束指定的测试, 并记录统计结果.\n*        end_custom 可以指定除'request', 'timeout' 之外自定义的测试结果类型.\n* @return token. 包含delay属性.\n*/\nfunction end_success(token)\nfunction end_failure(token)\nfunction end_custom(token, type)\n```\n\n```js\n/**\n* @desc: \b使用key来计数, 所欲偶测试进程的对同一个key的计数将累加.\n*        并且所有进程的计数操作将在测试结束后输出.\n* @return: \n*/\nfunction add_count(type, count=1) \n```\n\n```js\n/**\n * 测试电脑性能, 并输出信息得到进程数的参考值.\n * @param opt: \n *         {\n            minMemory,            // in byte, 保留的最小内存数.\n            logfile,              // 日志文件位置. null则不会存储.\n            }\n  */\nfunction testPerformance(opt)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainpoint%2Ffebs-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrainpoint%2Ffebs-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrainpoint%2Ffebs-test/lists"}