Browse Source

Adds perf tests.

Alliballibaba 2 months ago
parent
commit
6fa90d655d

+ 2 - 1
dev.Dockerfile

@@ -71,7 +71,8 @@ WORKDIR /usr/local/src/watcher
 RUN git clone https://github.com/e-dant/watcher . && \
 	cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && \
 	cmake --build build/ && \
-	cmake --install build
+	cmake --install build && \
+    ldconfig
 
 WORKDIR /go/src/app
 COPY . .

+ 23 - 0
testdata/k6/computation-heavy-with-io.js

@@ -0,0 +1,23 @@
+import http from 'k6/http';
+import { sleep } from 'k6';
+
+const ioLatencyMilliseconds = 5;
+const workIterations = 500000;
+const outputIterations = 50;
+
+export const options = {
+    stages: [
+        { duration: '20s', target: 10, },
+        { duration: '20s', target: 50 },
+        { duration: '20s', target: 0 },
+    ],
+    thresholds: {
+        http_req_failed: ['rate<0.01'],
+        http_req_duration: ['p(90)<150'],
+    },
+};
+
+export default function () {
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=${ioLatencyMilliseconds}&work=${workIterations}&output=${outputIterations}`);
+    //sleep(1);
+}

+ 23 - 0
testdata/k6/computation-heavy.js

@@ -0,0 +1,23 @@
+import http from 'k6/http';
+import {sleep} from 'k6';
+
+const ioLatencyMilliseconds = 0;
+const workIterations = 500000;
+const outputIterations = 150;
+
+export const options = {
+    stages: [
+        {duration: '20s', target: 25,},
+        {duration: '20s', target: 50},
+        {duration: '20s', target: 0},
+    ],
+    thresholds: {
+        http_req_failed: ['rate<0.01'],
+        http_req_duration: ['p(90)<150'],
+    },
+};
+
+export default function () {
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=${ioLatencyMilliseconds}&work=${workIterations}&output=${outputIterations}`);
+    //sleep(1);
+}

+ 23 - 0
testdata/k6/computation.js

@@ -0,0 +1,23 @@
+import http from 'k6/http';
+import { sleep } from 'k6';
+
+const ioLatencyMilliseconds = 0;
+const workIterations = 50000;
+const outputIterations = 50;
+
+export const options = {
+    stages: [
+        { duration: '20s', target: 40, },
+        { duration: '20s', target: 80 },
+        { duration: '20s', target: 0 },
+    ],
+    thresholds: {
+        http_req_failed: ['rate<0.01'],
+        http_req_duration: ['p(90)<150'],
+    },
+};
+
+export default function () {
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=${ioLatencyMilliseconds}&work=${workIterations}&output=${outputIterations}`);
+    //sleep(1);
+}

+ 24 - 0
testdata/k6/database.js

@@ -0,0 +1,24 @@
+import http from 'k6/http';
+import { sleep } from 'k6';
+
+/**
+ * Modern databases tend to have latencies in the single-digit milliseconds.
+ */
+export const options = {
+    stages: [
+        { duration: '20s', target: 50, },   // ramp up to concurrency 10 over 20s
+        { duration: '20s', target: 200 },    // ramp up to concurrency 25 over 20s
+        { duration: '20s', target: 0 },     // ramp down to 0 over 20s
+    ],
+    thresholds: {
+        http_req_failed: ['rate<0.01'],     // http errors should be less than 1%
+        http_req_duration: ['p(90)<5'],   // 90% of requests should be below 150ms
+    },
+};
+
+// simulate different latencies
+export default function () {
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=1work=5000&output=10`);
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=5work=5000&output=10`);
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=10work=5000&output=10`);
+}

+ 23 - 0
testdata/k6/db-request-fast.js

@@ -0,0 +1,23 @@
+import http from 'k6/http';
+import { sleep } from 'k6';
+
+const ioLatencyMilliseconds = 1;
+const workIterations = 5000;
+const outputIterations = 10;
+
+export const options = {
+    stages: [
+        { duration: '20s', target: 50, },   // ramp up to concurrency 10 over 20s
+        { duration: '20s', target: 200 },    // ramp up to concurrency 25 over 20s
+        { duration: '20s', target: 0 },     // ramp down to 0 over 20s
+    ],
+    thresholds: {
+        http_req_failed: ['rate<0.01'],     // http errors should be less than 1%
+        http_req_duration: ['p(90)<5'],   // 90% of requests should be below 150ms
+    },
+};
+
+export default function () {
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=${ioLatencyMilliseconds}&work=${workIterations}&output=${outputIterations}`);
+    //sleep(1);
+}

+ 23 - 0
testdata/k6/db-request-medium.js

@@ -0,0 +1,23 @@
+import http from 'k6/http';
+import { sleep } from 'k6';
+
+const ioLatencyMilliseconds = 5;
+const workIterations = 5000;
+const outputIterations = 10;
+
+export const options = {
+    stages: [
+        { duration: '20s', target: 50, },   // ramp up to concurrency 10 over 20s
+        { duration: '20s', target: 200 },    // ramp up to concurrency 25 over 20s
+        { duration: '20s', target: 0 },     // ramp down to 0 over 20s
+    ],
+    thresholds: {
+        http_req_failed: ['rate<0.01'],     // http errors should be less than 1%
+        http_req_duration: ['p(90)<10'],   // 90% of requests should be below 150ms
+    },
+};
+
+export default function () {
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=${ioLatencyMilliseconds}&work=${workIterations}&output=${outputIterations}`);
+    //sleep(1);
+}

+ 23 - 0
testdata/k6/db-request-slow.js

@@ -0,0 +1,23 @@
+import http from 'k6/http';
+import { sleep } from 'k6';
+
+const ioLatencyMilliseconds = 10;
+const workIterations = 5000;
+const outputIterations = 10;
+
+export const options = {
+    stages: [
+        { duration: '20s', target: 50, },   // ramp up to concurrency 10 over 20s
+        { duration: '20s', target: 200 },    // ramp up to concurrency 25 over 20s
+        { duration: '20s', target: 0 },     // ramp down to 0 over 20s
+    ],
+    thresholds: {
+        http_req_failed: ['rate<0.01'],     // http errors should be less than 1%
+        http_req_duration: ['p(90)<20'],   // 90% of requests should be below 150ms
+    },
+};
+
+export default function () {
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=${ioLatencyMilliseconds}&work=${workIterations}&output=${outputIterations}`);
+    //sleep(1);
+}

+ 23 - 0
testdata/k6/external-api-fast.js

@@ -0,0 +1,23 @@
+import http from 'k6/http';
+import { sleep } from 'k6';
+
+const ioLatencyMilliseconds = 40;
+const workIterations = 5000;
+const outputIterations = 10;
+
+export const options = {
+    stages: [
+        { duration: '20s', target: 50, },   // ramp up to concurrency 10 over 20s
+        { duration: '20s', target: 200 },    // ramp up to concurrency 25 over 20s
+        { duration: '20s', target: 0 },     // ramp down to 0 over 20s
+    ],
+    thresholds: {
+        http_req_failed: ['rate<0.01'],     // http errors should be less than 1%
+        http_req_duration: ['p(90)<150'],   // 90% of requests should be below 150ms
+    },
+};
+
+export default function () {
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=${ioLatencyMilliseconds}&work=${workIterations}&output=${outputIterations}`);
+    //sleep(1);
+}

+ 23 - 0
testdata/k6/external-api-medium.js

@@ -0,0 +1,23 @@
+import http from 'k6/http';
+import { sleep } from 'k6';
+
+const ioLatencyMilliseconds = 150;
+const workIterations = 5000;
+const outputIterations = 10;
+
+export const options = {
+    stages: [
+        { duration: '20s', target: 100, },   // ramp up to concurrency 10 over 20s
+        { duration: '20s', target: 400 },    // ramp up to concurrency 25 over 20s
+        { duration: '20s', target: 0 },     // ramp down to 0 over 20s
+    ],
+    thresholds: {
+        http_req_failed: ['rate<0.01'],     // http errors should be less than 1%
+        http_req_duration: ['p(90)<200'],   // 90% of requests should be below 150ms
+    },
+};
+
+export default function () {
+    http.get(`${__ENV.CADDY_HOSTNAME}/sleep.php?sleep=${ioLatencyMilliseconds}&work=${workIterations}&output=${outputIterations}`);
+    //sleep(1);
+}

Some files were not shown because too many files changed in this diff