diff third_party/wrk/src/wrk.h @ 178:94705b5986b3

[ThirdParty] Added WRK and luajit for load testing.
author MrJuneJune <me@mrjunejune.com>
date Thu, 22 Jan 2026 20:10:30 -0800
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/third_party/wrk/src/wrk.h	Thu Jan 22 20:10:30 2026 -0800
@@ -0,0 +1,66 @@
+#ifndef WRK_H
+#define WRK_H
+
+#include "config.h"
+#include <pthread.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <netdb.h>
+#include <sys/socket.h>
+
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+#include <lua.h>
+
+#include "stats.h"
+#include "ae.h"
+#include "http_parser.h"
+
+#define RECVBUF  8192
+
+#define MAX_THREAD_RATE_S   10000000
+#define SOCKET_TIMEOUT_MS   2000
+#define RECORD_INTERVAL_MS  100
+
+extern const char *VERSION;
+
+typedef struct {
+    pthread_t thread;
+    aeEventLoop *loop;
+    struct addrinfo *addr;
+    uint64_t connections;
+    uint64_t complete;
+    uint64_t requests;
+    uint64_t bytes;
+    uint64_t start;
+    lua_State *L;
+    errors errors;
+    struct connection *cs;
+} thread;
+
+typedef struct {
+    char  *buffer;
+    size_t length;
+    char  *cursor;
+} buffer;
+
+typedef struct connection {
+    thread *thread;
+    http_parser parser;
+    enum {
+        FIELD, VALUE
+    } state;
+    int fd;
+    SSL *ssl;
+    bool delayed;
+    uint64_t start;
+    char *request;
+    size_t length;
+    size_t written;
+    uint64_t pending;
+    buffer headers;
+    buffer body;
+    char buf[RECVBUF];
+} connection;
+
+#endif /* WRK_H */