1
0
mirror of https://github.com/wg/wrk synced 2025-01-08 06:52:55 +08:00

Compare commits

..

1 Commits

Author SHA1 Message Date
Vladimir Chebotarev
68fd91b7bf
Merge 8bc5fd1ab5 into a211dd5a70 2024-08-23 05:30:42 +03:00
3 changed files with 5 additions and 14 deletions

View File

@ -45,7 +45,7 @@ static const struct luaL_Reg threadlib[] = {
{ NULL, NULL }
};
lua_State *script_create(char *file, char *url, char *method, char *data, char **headers) {
lua_State *script_create(char *file, char *url, char *method, char **headers) {
lua_State *L = luaL_newstate();
luaL_openlibs(L);
(void) luaL_dostring(L, "wrk = require \"wrk\"");
@ -79,8 +79,6 @@ lua_State *script_create(char *file, char *url, char *method, char *data, char *
set_field(L, 4, "port", push_url_part(L, url, &parts, UF_PORT));
lua_pushstring(L, method);
set_field(L, 4, "method", 0);
lua_pushstring(L, data);
set_field(L, 4, "body", 0);
set_fields(L, 4, fields);
lua_getfield(L, 4, "headers");

View File

@ -9,7 +9,7 @@
#include "stats.h"
#include "wrk.h"
lua_State *script_create(char *, char *, char *, char *, char **);
lua_State *script_create(char *, char *, char *, char **);
bool script_resolve(lua_State *, char *, char *);
void script_setup(lua_State *, thread *);

View File

@ -15,7 +15,6 @@ static struct config {
bool latency;
char *host;
char *method;
char *data;
char *script;
SSL_CTX *ctx;
} cfg;
@ -53,7 +52,6 @@ static void usage() {
" -s, --script <S> Load Lua script file \n"
" -X, --method <S> HTTP method (default: GET) \n"
" -H, --header <H> Add header to request \n"
" --data <S> Body \n"
" --latency Print latency statistics \n"
" --timeout <T> Socket/request timeout \n"
" -v, --version Print version details \n"
@ -96,7 +94,7 @@ int main(int argc, char **argv) {
statistics.requests = stats_alloc(MAX_THREAD_RATE_S);
thread *threads = zcalloc(cfg.threads * sizeof(thread));
lua_State *L = script_create(cfg.script, url, cfg.method, cfg.data, headers);
lua_State *L = script_create(cfg.script, url, cfg.method, headers);
if (!script_resolve(L, host, service)) {
char *msg = strerror(errno);
fprintf(stderr, "unable to connect to %s:%s %s\n", host, service, msg);
@ -110,7 +108,7 @@ int main(int argc, char **argv) {
t->loop = aeCreateEventLoop(10 + cfg.connections * 3);
t->connections = cfg.connections / cfg.threads;
t->L = script_create(cfg.script, url, cfg.method, cfg.data, headers);
t->L = script_create(cfg.script, url, cfg.method, headers);
script_init(L, t, argc - optind, &argv[optind]);
if (i == 0) {
@ -477,7 +475,6 @@ static struct option longopts[] = {
{ "script", required_argument, NULL, 's' },
{ "method", required_argument, NULL, 'X' },
{ "header", required_argument, NULL, 'H' },
{ "data", required_argument, NULL, 'D' },
{ "latency", no_argument, NULL, 'L' },
{ "timeout", required_argument, NULL, 'T' },
{ "help", no_argument, NULL, 'h' },
@ -495,9 +492,8 @@ static int parse_args(struct config *cfg, char **url, struct http_parser_url *pa
cfg->duration = 10;
cfg->timeout = SOCKET_TIMEOUT_MS;
cfg->method = "GET";
cfg->data = "";
while ((c = getopt_long(argc, argv, "t:c:d:D:s:X:H:T:Lrv?", longopts, NULL)) != -1) {
while ((c = getopt_long(argc, argv, "t:c:d:s:X:H:T:Lrv?", longopts, NULL)) != -1) {
switch (c) {
case 't':
if (scan_metric(optarg, &cfg->threads)) return -1;
@ -517,9 +513,6 @@ static int parse_args(struct config *cfg, char **url, struct http_parser_url *pa
case 'H':
*header++ = optarg;
break;
case 'D':
cfg->data = optarg;
break;
case 'L':
cfg->latency = true;
break;