{"id":17234774,"url":"https://github.com/guonaihong/gurl","last_synced_at":"2025-03-22T18:34:19.891Z","repository":{"id":77683645,"uuid":"127752785","full_name":"guonaihong/gurl","owner":"guonaihong","description":"Gurl is a performance testing tool. The supported protocols are http, websocket, tcp. Of course, it also supports access in non-bench mode.  gurl是性能测试工具，支持的协议有http, websocket，tcp。当然也支持非bench模式下的访问","archived":false,"fork":false,"pushed_at":"2019-11-01T12:43:04.000Z","size":247,"stargazers_count":36,"open_issues_count":1,"forks_count":10,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-01T17:51:31.039Z","etag":null,"topics":["benchmark-tool","curl","gurl"],"latest_commit_sha":null,"homepage":"","language":"Go","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/guonaihong.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-02T12:23:57.000Z","updated_at":"2024-10-21T08:48:28.000Z","dependencies_parsed_at":"2023-03-02T10:30:22.152Z","dependency_job_id":null,"html_url":"https://github.com/guonaihong/gurl","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guonaihong%2Fgurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guonaihong%2Fgurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guonaihong%2Fgurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guonaihong%2Fgurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guonaihong","download_url":"https://codeload.github.com/guonaihong/gurl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245003583,"owners_count":20545633,"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":["benchmark-tool","curl","gurl"],"created_at":"2024-10-15T05:30:31.596Z","updated_at":"2025-03-22T18:34:19.561Z","avatar_url":"https://github.com/guonaihong.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gurl\n#### Documentation\n* [English](./README_EN.md)\n\n[![Build Status](https://travis-ci.org/guonaihong/gurl.png)](https://travis-ci.org/guonaihong/gurl)\n#### 简介\ngurl 是http, websocket bench工具和curl的继承者\n\n#### 功能\n* 多协议支持http, websocket\n* 支持curl常用命令行选项\n* 支持压测模式，可以根据并发数和线程数，也可以根据持续时间，也可以指定每秒并发数压测http, websocket, tcp服务\n* url 支持简写\n* 支持管道模式\n\n#### install\n```bash\nenv GOPATH=`pwd` go get -u github.com/guonaihong/gurl/\n```\n\n#### gurl 主命令选项\n- [http 子命令](#http-子命令)\n- [websocket 子命令](#websocket-子命令)\n#### http 子命令\n- [http 性能压测](#http-性能压测)\n- [RESTful API](#restful-api)\n\n```console\nguonaihong https://github.com/guonaihong/gurl\n\nUsage of gurl:\n  -A, --user-agent string\n    \tSend User-Agent STRING to server (default \"gurl\")\n  -F, --form string[]\n    \tSpecify HTTP multipart POST data (H) (default [])\n  -H, --header string[]\n    \tPass custom header LINE to server (H) (default [])\n  -I, --input-model\n    \topen input mode\n  -J string[]\n    \tTurn key:value into {\"key\": \"value\"})\n  -Jfa string[]\n    \tSpecify HTTP multipart POST json data (H)\n  -Jfa-string string[]\n    \tSpecify HTTP multipart POST json data (H)\n  -O, --output-mode\n    \topen output mode\n  -R, --input-read string\n    \topen input file\n  -W, --output-write string\n    \topen output file\n  -X, --request string\n    \tSpecify request command to use\n  -ac int\n    \tNumber of multiple requests to make (default 1)\n  -an int\n    \tNumber of requests to perform (default 1)\n  -bench\n    \tRun benchmarks test\n  -c, --color\n    \tColor highlighting\n  -connect-timeout string\n    \tMaximum time allowed for connection\n  -conns int\n    \tMax open idle connections per target host (default 10000)\n  -cpus int\n    \tNumber of CPUs to use\n  -d, --data string\n    \tHTTP POST data\n  -debug\n    \topen debug mode\n  -duration string\n    \tDuration of the test\n  -form-string string[]\n    \tSpecify HTTP multipart POST data (H) (default [])\n  -input-fields string\n    \tsets the field separator (default \" \")\n  -l string\n    \tListen mode, HTTP echo server\n  -m, --merge\n    \tCombine the output results into the output\n  -o, --output string\n    \tWrite to FILE instead of stdout (default \"stdout\")\n  -oflag string\n    \tControl the way you write(append|line|trunc)\n  -q, --query string[]\n    \tquery string\n  -r, --read-stream\n    \tRead data from the stream\n  -rate int\n    \tRequests per second\n  -skey, --input-setkey string\n    \tSet a new name for the default key\n  -url string\n    \tSpecify a URL to fetch\n  -v, --verbose\n    \tMake the operation more talkative\n  -w, --write-stream\n    \tWrite data from the stream\n  -wkey, --write-key string\n    \tKey that can be write\n\n```\n##### `-F 或 --form`\n设置form表单, 比如-F text=文本内容，或者-F text=@./从文件里面读取, -F 选项的语义和curl命令一样\n##### `--form-string`\n和-F 或--form类似，不解释@符号，原样传递到服务端\n\n##### `-ac`\n指定线程数, 开ac个线程, 发送an个请求\n```bash\ngurl http -an 10 -ac 2 -F text=good :1234\n```\n\n##### `-an`\n指定次数\n\n##### http 性能压测\n`-bench`\n压测模式，可以对http服务端进行压测，可以和-ac, -an, -duration, -rate 选项配合使用\n ``` console\n    gurl http -bench -ac 25 -an 1000000 :1234\n    Benchmarking 127.0.0.1 (be patient)\n      Completed          100000 requests [2018-08-11 21:58:56.143]\n      Completed          200000 requests [2018-08-11 21:59:00.374]\n      Completed          300000 requests [2018-08-11 21:59:03.703]\n      Completed          400000 requests [2018-08-11 21:59:06.559]\n      Completed          500000 requests [2018-08-11 21:59:09.201]\n      Completed          600000 requests [2018-08-11 21:59:11.757]\n      Completed          700000 requests [2018-08-11 21:59:14.218]\n      Completed          800000 requests [2018-08-11 21:59:16.639]\n      Completed          900000 requests [2018-08-11 21:59:19.061]\n      Completed         1000000 requests [2018-08-11 21:59:21.451]\n      Finished          1000000 requests\n\n\n    Server Software:        gurl-server\n    Server Hostname:        \n    Server Port:            1234\n\n    Document Path:          \n    Document Length:        0 bytes\n\n    Status Codes:           200:1000000  [code:count]\n    Concurrency Level:      10\n    Time taken for tests:   28.807 seconds\n    Complete requests:      1000000\n    Failed requests:        0\n    Total transferred:      137000000 bytes\n    HTML transferred:       0 bytes\n    Requests per second:    34713.37 [#/sec] (mean)\n    Time per request:       0.288 [ms] (mean)\n    Time per request:       0.029 [ms] (mean, across all concurrent requests)\n    Transfer rate:          4755.73 [Kbytes/sec] received\n    Percentage of the requests served within a certain time (ms)\n      50%    0.21ms\n      66%    0.31ms\n      75%    0.38ms\n      80%    0.42ms\n      90%    0.57ms\n      95%    0.66ms\n      98%    0.79ms\n      99%    0.89ms\n     100%    16.45ms\n\n ```\n\n##### `-duration`\n和-bench选项一起使用，可以控制压测时间，支持单位符,ms(毫秒), s(秒), m(分), h(小时), d(天), w(周), M(月), y(年)\n也可以混合使用 -duration 1m10s\n\n##### `-connect-timeout`\n设置http 连接超时时间。支持单位符,ms(毫秒), s(秒), m(分), h(小时), d(天), w(周), M(月), y(年)\n\n##### `-rate`\n指定每秒写多少条\n``` console\ngurl http -bench -ac 25 -an 3000 -rate 3000 :1234\nBenchmarking 127.0.0.1 (be patient)\n  Completed             300 requests [2018-08-11 22:02:01.625]\n  Completed             600 requests [2018-08-11 22:02:01.725]\n  Completed             900 requests [2018-08-11 22:02:01.825]\n  Completed            1200 requests [2018-08-11 22:02:01.925]\n  Completed            1500 requests [2018-08-11 22:02:02.025]\n  Completed            1800 requests [2018-08-11 22:02:02.125]\n  Completed            2100 requests [2018-08-11 22:02:02.225]\n  Completed            2400 requests [2018-08-11 22:02:02.325]\n  Completed            2700 requests [2018-08-11 22:02:02.425]\n  Completed            3000 requests [2018-08-11 22:02:02.525]\n  Finished             3000 requests\n\n\nServer Software:        gurl-server\nServer Hostname:        \nServer Port:            1234\n\nDocument Path:          \nDocument Length:        0 bytes\n\nStatus Codes:           200:3000  [code:count]\nConcurrency Level:      10\nTime taken for tests:   1.000 seconds\nComplete requests:      3000\nFailed requests:        0\nTotal transferred:      411000 bytes\nHTML transferred:       0 bytes\nRequests per second:    3000.08 [#/sec] (mean)\nTime per request:       3.333 [ms] (mean)\nTime per request:       0.333 [ms] (mean, across all concurrent requests)\nTransfer rate:          411.01 [Kbytes/sec] received\nPercentage of the requests served within a certain time (ms)\n  50%    0.17ms\n  66%    0.18ms\n  75%    0.18ms\n  80%    0.19ms\n  90%    0.21ms\n  95%    0.23ms\n  98%    0.26ms\n  99%    0.31ms\n 100%    1.34ms\n```\n##### `-d 或 --data`\n发送http body数据到服务端, 支持@符号打开一个文件, 如果不接@直接把-d后面字符串发送到服务端\n```bash\n  gurl http -d \"good\" :12345\n  gurl http -d \"@./file\" :12345\n```\n\n##### RESTful API\n`-J` 拼装json字段到body里面\n-J 后面的key和value 会被组装成json字符串发送到服务端. key:value，其中value会被解释成字符串, key:=value，value会被解决成bool或者数字或者小数\n  * 普通用法\n   ```bash\n    ./gurl http -J username:admin passwd:123456 bool_val:=true  int_val:=3 float_val:=0.3 -url http://127.0.0.1:12345\n    {\n        \"bool_val\": true,\n        \"float_val\": 0.3,\n        \"int_val\": 3,\n        \"passwd\": \"123456\",\n        \"username\": \"admin\"\n    }\n   ```\n  * 嵌套用法\n  ```bash\n  ./gurl http -J a.b.c.d:=true -J a.b.c.e:=111 http://127.0.0.1:12345\n  {\n    \"a\": {\n      \"b\": {\n        \"c\": {\n          \"d:\": true,\n          \"e:\": 111\n        }\n      }\n    }\n  }\n  ```\n##### 查询字符串\n`-q` 后跟查询字符串, key=val形式\n\n```bash\ngurl http -X POST -J hello:word startTime:123 endTime:456 -url :8080/test -vc -q appkey=hello world=hello\n\u003e POST /test?appkey=hello\u0026world=hello HTTP/1.1\n\u003e Accept: */*\n\u003e Host: 127.0.0.1:8080\n\u003e User-Agent: gurl\n\u003e\n\n\u003c HTTP/1.1 200 OK\n\u003c Date: Tue, 21 May 2019 12:39:13 GMT\n\u003c Content-Length: 50\n\u003c Content-Type: text/plain; charset=utf-8\n\n\n{\n  \"endTime\": \"456\",\n  \"hello\": \"word\",\n  \"startTime\": \"123\"\n}\n\n```\n##### `-Jfa`\n向multipart字段中插入json数据\n```bash\n./gurl http -Jfa text=DisplayText:good text=Language:cn text2=look:me -F text=good :12345\n\n--4361c4e6ae1b083e9e0508a7b40eb215bccd265c4bed00137cc7d112e890\nContent-Disposition: form-data; name=\"text\"\n\n{\"DisplayText\":\"good\",\"Language\":\"cn\"}\n--4361c4e6ae1b083e9e0508a7b40eb215bccd265c4bed00137cc7d112e890\nContent-Disposition: form-data; name=\"text2\"\n\n{\"look\":\"me\"}\n--4361c4e6ae1b083e9e0508a7b40eb215bccd265c4bed00137cc7d112e890\nContent-Disposition: form-data; name=\"text\"\n\ngood\n--4361c4e6ae1b083e9e0508a7b40eb215bccd265c4bed00137cc7d112e890--\n```\n##### `-Jfa-string`\n和-Jfa语法类似，不解析@符号\n\n##### `-H 或者 --header`\n设置http 头，可以指定多个\n```bash\n./gurl http -H \"header1:value1\" -H \"header2:value2\" http://xxx.xxx.xxx.xxx:port\n```\n\n##### `-url`\n设置http url的地址, 可以使用简写\n* -url http://127.0.0.1:1234 --\u003e 127.0.0.1:1234\n* -url http://127.0.0.1:1234 --\u003e :1234\n* -url http://127.0.0.1/path --\u003e /path\n\n##### `-oflag`\n-oflag 一般和-o选项配合使用(控制写文件的行为)\n* -oflag append 默认-o的行为是新建文件然后写入，如果开启-ac -an选项，可以使用append肥所有的结果保存到一个文件中\n* -oflag line 如果服务端返回的结果，想使用换行符分隔  \n小提示: -oflag 后面的命令可以组合使用 \"append|line\"的意思是：把服务端的输出追加到某个文本中，并用'\\n'分隔符\n\n\n#### 高级主题(stream功能)\n##### `-I`\n打开input模式\n\n##### `-R`\n打开列表文件, 可以使用-input-fields 指定分割符，默认是空格\n\n##### `-skey`\n给默认的名字取个别名，相当于取个好听的变量名，方便后面引用\n\n##### `-r`\n从流里面读取数据\n\n##### `-w`\n结果输出到流\n\n##### `-merge`\n把输入流里面的结果和识别结果组成大的结果，写到输出流\n\n##### `-O`\n打开output模式\n\n##### `-wkey`\n控制写出的json key\n\n##### `|`\n管道符主要拼接多个gurl功能块\n\n##### 批量访问多个url\n开5个线程访问url.list里面的url列表\n```\ncat url.list\n\ngithub.com\nwww.baidu.com\nwww.qq.com\nwww.taobao.com\n\ngurl http -I -R url.list -skey \"url=rf.col.0\" \"|\" -ac 5 -r -w -merge \"{url}\" -o \"/dev/null\" \"|\" -O -wkey \"status_code\"\n```\n\n#### TODO\n* 集群模式\n* GUI\n\n#### websocket 子命令\n\n#### 命令行选项\n```console\nguonaihong https://github.com/guonaihong/wsurl\n\nUsage of gurl:\n  -A, --user-agent string\n    \tSend User-Agent STRING to server (default \"gurl\")\n  -H, --header string[]\n    \tPass custom header LINE to server (H) (default [])\n  -I, --input-model\n    \topen input mode\n  -O, --output-mode\n    \topen output mode\n  -R, --input-read string\n    \topen input file\n  -W, --output-write string\n    \topen output file\n  -ac int\n    \tNumber of multiple requests to make (default 1)\n  -an int\n    \tNumber of requests to perform (default 1)\n  -bench\n    \tRun benchmarks test\n  -binary\n    \tSend binary messages instead of utf-8\n  -close\n    \tSend close message\n  -duration string\n    \tDuration of the test\n  -fsa, --first-send-after string\n    \tWait for the first time before sending\n  -input-fields string\n    \tsets the field separator (default \" \")\n  -l string\n    \tListen mode, websocket echo server\n  -ld, --last-packet string\n    \tThe last packet is written to the connection\n  -m, --merge\n    \tCombine the output results into the output\n  -o, --output string\n    \tWrite to FILE instead of stdout (default \"stdout\")\n  -p, --packet string[]\n    \tData packet to be send per connection\n  -r, --read-stream\n    \tRead data from the stream\n  -rate int\n    \tRequests per second\n  -send-rate string\n    \tHow many bytes of data in seconds\n  -skey, --input-setkey string\n    \tSet a new name for the default key\n  -url string\n    \tSpecify a URL to fetch\n  -w, --write-stream\n    \tWrite data from the stream\n  -wkey, --write-key string\n    \tKey that can be write\n\n```\n\n##### `-H 或header`\n设置websocket 的header和http header类似\n\n##### `-p 或 --packet`\n发送websocket body数据到服务端，支持@符号打开一个文件, 如果不接@直接把-d后面字符串发送到服务端\n```bash\n  wsurl -p \"good\" :12345\n  wsurl -p \"@./file\" :12345\n```\n##### `-send-rate`\n``` bash\n# 指定每多少ms发多少字节\nwsurl -send-rate \"8000B/250ms\" -url ws://127.0.0.1:24986\n```\n\n##### `-binary`\n默认是以text格式作为websocket消息类型, 加上-binary就以text作为消息类型\n\n##### `-ld`\n发送最后一个websocket包的内容\n```bash\n  wsurl -ld \"good\" :12345\n  wsurl -ld \"@./file\" :12345\n```\n\n##### `-url`\n设置websocket的url\n* -url http://127.0.0.1:1234 --\u003e 127.0.0.1:1234\n* -url http://127.0.0.1:1234 --\u003e :1234\n* -url http://127.0.0.1/path --\u003e /path\n\n##### `-ac`\n指定线程数, 开ac个线程, 发送an个请求\n```bash\nwsurl -an 10 -ac 2 -F text=good :1234\n```\n\n##### `-an`\n指定次数\n\n##### `-duration`\n和-bench选项一起使用，可以控制压测时间，支持单位符,s(秒), m(分), h(小时), d(天), w(周), M(月), y(年), ms(毫秒)\n也可以混合使用 -duration 1m10s\n\n##### `-rate`\n指定每秒写多少条，目前只有打开-bench选项才起作用\n\n##### `-close`\n客户端主动发起close消息给服务端\n\n##### `-bench`\n压测模式\nwsurl -bench -ac 20 -an 10000 -url :33333 -close\n``` console\nConnecting to to ws://127.0.0.1:33333\n    Opened            1000 connections: [2018-08-23 20:50:55.987]\n    Opened            2000 connections: [2018-08-23 20:50:56.129]\n    Opened            3000 connections: [2018-08-23 20:50:56.266]\n    Opened            4000 connections: [2018-08-23 20:50:56.409]\n    Opened            5000 connections: [2018-08-23 20:50:56.552]\n    Opened            6000 connections: [2018-08-23 20:50:56.684]\n    Opened            7000 connections: [2018-08-23 20:50:56.835]\n    Opened            8000 connections: [2018-08-23 20:50:56.098]\n    Opened            9000 connections: [2018-08-23 20:50:57.125]\n    Opened           10000 connections: [2018-08-23 20:50:57.268]\n\n    Finished 10000 connections\n\nConcurrency Level:        20\nTime taken for tests:     1.432677765s\nConnected:                10000\nDisconnected:             0\nFailed:                   0\nTotal transferred:        0\nTotal received            0\nRequests per second:      6979 [#/sec] (mean)\nTime per request:         716338.883 [ms] (mean)\nTime per request:         71.634 [ms] (mean, across all concurrent requests)\nTransfer rate:            0.000 [Kbytes/sec] received\n\nPercentage of the requests served within a certain time (ms)\n    50%    2.00ms\n    66%    2.00ms\n    75%    3.00ms\n    80%    3.00ms\n    90%    4.00ms\n    95%    6.00ms\n    98%    7.00ms\n    99%    9.00ms\n    100%   21.00ms\n```\n\n#### 高级主题(stream功能)\n##### `-I`\n打开input模式\n\n##### `-R`\n打开列表文件, 可以使用-input-fields 指定分割符，默认是空格\n\n##### `-skey`\n给默认的名字取个别名，相当于取个好听的变量名，方便后面引用\n\n##### `-r`\n从流里面读取数据\n\n##### `-w`\n结果输出到流\n\n##### `-merge`\n把输入流里面的结果和识别结果组成大的结果，写到输出流\n\n##### `-O`\n打开output模式\n\n##### `-wkey`\n控制写出的json key\n\n##### `|`\n管道符主要拼接多个gurl功能块\n\n#### tcp, udp 子命令用法\n* [tcp udp](./conn/README.md)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguonaihong%2Fgurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguonaihong%2Fgurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguonaihong%2Fgurl/lists"}