Jelajahi Sumber

fix: update latency test

Sv443 1 tahun lalu
induk
melakukan
3e22931b68
1 mengubah file dengan 8 tambahan dan 3 penghapusan
  1. 8 3
      test/latency-test.ts

+ 8 - 3
test/latency-test.ts

@@ -3,16 +3,15 @@
 
 import "dotenv/config";
 import _axios from "axios";
-//@ts-ignore
 import percentile from "percentile";
 
 const settings = {
-  amount: 50,
+  amount: 100,
   url: `http://127.0.0.1:${process.env.HTTP_PORT}/search/top?q=pink guy - dog festival directions`,
 };
 
 
-const axios = _axios.create({ timeout: 10_000 });
+const axios = _axios.create({ timeout: 20_000 });
 
 async function run() {
   console.log(`\n\n>>> Running latency test with ${settings.amount} requests...\n`);
@@ -33,13 +32,19 @@ async function run() {
   }
 
   const avg = (times.reduce((a, c) => a + c, 0) / times.length).toFixed(0);
+  const max = times.reduce((a, c) => Math.max(a, c), 0).toFixed(0);
   const perc80 = percentile(80, times);
+  const perc90 = percentile(90, times);
   const perc95 = percentile(95, times);
   const perc99 = percentile(99, times);
 
   console.log(`\n>>> Latency test finished after ${((Date.now() - startTs) / 1000).toFixed(2)}s`);
+  console.log();
   console.log(`avg:\t${avg}\tms`);
+  console.log(`max:\t${max}\tms`);
+  console.log();
   console.log(`80th%:\t${perc80}\tms`);
+  console.log(`90th%:\t${perc90}\tms`);
   console.log(`95th%:\t${perc95}\tms`);
   console.log(`99th%:\t${perc99}\tms`);
   console.log();