« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xindex.js42
-rw-r--r--stress-test.txt16
m---------tui-lib0
3 files changed, 46 insertions, 12 deletions
diff --git a/index.js b/index.js
index 15392bd..f1073e0 100755
--- a/index.js
+++ b/index.js
@@ -82,23 +82,47 @@ async function main() {
     root.fixAllLayout()
   })
 
+  const loadPlaylists = async () => {
+    for (let i = 2; i < process.argv.length; i++) {
+      await appElement.handlePlaylistSource(process.argv[i], true)
+    }
+  }
+
+  const loadPlaylistPromise = loadPlaylists()
+
   if (process.argv.includes('--stress-test')) {
+    await loadPlaylistPromise
+
     const w = 80
     const h = 40
     flushable.resizeScreen({lines: w, cols: h})
     root.w = w
     root.h = h
     root.fixAllLayout()
-    const start = Date.now()
-    let n = 0
-    while (Date.now() < start + 1000) {
+
+    const stress = func => {
+      const start = Date.now()
+      let n = 0
+      while (Date.now() < start + 1000) {
+        func()
+        n++
+      }
+      return n
+    }
+
+    const nRenderAndFlush = stress(() => {
       root.renderTo(flushable)
       flushable.flush()
-      n++
-    }
+    })
+
+    const nFixAllLayout = stress(() => {
+      root.fixAllLayout()
+    })
+
+    process.stdout.write(ansi.cleanCursor() + ansi.clearScreen() + '\n')
+    console.log('# of times we can render & flush:', nRenderAndFlush)
+    console.log('# of times we can fix all layout:', nFixAllLayout)
 
-    console.log(ansi.clearScreen() + ansi.cleanCursor())
-    console.log('# of times ran:', n)
     process.exit(0)
 
     return
@@ -108,10 +132,6 @@ async function main() {
     root.renderTo(flushable)
     flushable.flush()
   }, 50)
-
-  for (let i = 2; i < process.argv.length; i++) {
-    await appElement.handlePlaylistSource(process.argv[i], true)
-  }
 }
 
 main().catch(err => {
diff --git a/stress-test.txt b/stress-test.txt
index bc4b2e8..4447fdf 100644
--- a/stress-test.txt
+++ b/stress-test.txt
@@ -1,4 +1,18 @@
-# of times ran
 - With cached getCursorIndex(): 900
 - With (broken) less objects: ...still 900 [REMOVED]
 - With less attributes.slice(): 1000
+
+
+**** New stress test!! Passing misc-playlists/modland.json ***
+
+- d712d40 (Original code):
+   Render & Flush - 1
+   Fix All Layout - 1
+
+- ae2c9e1 Optimize getScrollPositionOfElementAtEndOfView:
+   Render & Flush - 520
+   Fix All Layout - 80
+
+- d544986 Optimize the h*ck out of ListScrollForm
+   Render & Flush - 520
+   Fix All Layout - 440
diff --git a/tui-lib b/tui-lib
-Subproject d712d405f76178fc67b9421c113dccc3537e2a0
+Subproject d54498610d53e8c8a437a6adff0ced11b037afe