From f8077a21b108408a08e9a19d5235398794d806e0 Mon Sep 17 00:00:00 2001
From: Richard Petersen <richard.petersen@open-xchange.com>
Date: Tue, 30 Aug 2022 10:54:43 +0200
Subject: [PATCH] Improve all-files performance test

- Measure once with warm, once with cold cache
- Divide the requests into 5 threads


(cherry picked from commit ad4cd5b57ebe3223d10b3eb5a0c619f899cf661a)
---
 performance-tests/all-files.js | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/performance-tests/all-files.js b/performance-tests/all-files.js
index f38fd90..bf0104c 100644
--- a/performance-tests/all-files.js
+++ b/performance-tests/all-files.js
@@ -38,21 +38,41 @@ const uiMWPath = process.env.UI_MIDDLEWARE_PATH
 // 4. collect manifests from the ui-container (or already do that in 1.)
 const manifests = await result.json()
 
-// 5. setup autocannon options with all files
+// 5.1 setup autocannon with cold cache
 console.log('Setup finished, start autocannon...')
 await new Promise(resolve => setTimeout(resolve, 50))
-const testResult = await autocannon({
+const coldCacheResult = await autocannon({
   url: uiMWPath,
   connections: 1,
   duration: 60,
   requests: Object.values(manifests).map(({ file }) => ({
     path: new URL(file, uiMWPath).href
-  }))
+  })),
+  workers: 5
 })
 
-// 6. handle result
+// 6.1 handle result
 await new Promise(resolve => setTimeout(resolve, 50))
-console.log(autocannon.printResult(testResult))
+console.log('Autocannon results with cold cache:')
+console.log(autocannon.printResult(coldCacheResult))
+
+// 5.2 setup autocannon options with all files
+console.log('Setup finished, start autocannon with warm cache...')
+await new Promise(resolve => setTimeout(resolve, 50))
+const warmCacheResult = await autocannon({
+  url: uiMWPath,
+  connections: 1,
+  duration: 60,
+  requests: Object.values(manifests).map(({ file }) => ({
+    path: new URL(file, uiMWPath).href
+  })),
+  workers: 5
+})
+
+// 6.2 handle result
+await new Promise(resolve => setTimeout(resolve, 50))
+console.log('Autocannon results with warm cache:')
+console.log(autocannon.printResult(warmCacheResult))
 
 // 7. restore old config
 try {
-- 
GitLab