summaryrefslogtreecommitdiffstats
path: root/src/testdir/popupbounce.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-06-10 21:24:12 +0200
committerBram Moolenaar <Bram@vim.org>2019-06-10 21:24:12 +0200
commit4c063a0dab57be7bd7aad4b8434feff3db5f1057 (patch)
treee73db7e8dfa79610e7c4b1a4a846688cf0f1b04f /src/testdir/popupbounce.vim
parent640d4f0c97e686211dc4474b46a83e4435d883c0 (diff)
patch 8.1.1517: when a popup changes all windows are redrawnv8.1.1517
Problem: When a popup changes all windows are redrawn. Solution: Only update the lines that were affected. Add a file for profiling popup windows efficiency.
Diffstat (limited to 'src/testdir/popupbounce.vim')
-rw-r--r--src/testdir/popupbounce.vim80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/testdir/popupbounce.vim b/src/testdir/popupbounce.vim
new file mode 100644
index 0000000000..2d1345bfd5
--- /dev/null
+++ b/src/testdir/popupbounce.vim
@@ -0,0 +1,80 @@
+" Use this script to measure the redrawing performance when a popup is being
+" displayed. Usage with gcc:
+" cd src
+" # Edit Makefile to uncomment PROFILE_CFLAGS and PROFILE_LIBS
+" make reconfig
+" ./vim --clean -S testdir/popupbounce.vim main.c
+" gprof vim gmon.out | vim -
+
+" using line contination
+set nocp
+
+" don't switch screens when quitting, so we can read the frames/sec
+set t_te=
+
+let winid = popup_create(['line1', 'line2', 'line3', 'line4'], {
+ \ 'line' : 1,
+ \ 'col' : 1,
+ \ 'zindex' : 101,
+ \ })
+redraw
+
+let start = reltime()
+let framecount = 0
+
+let line = 1.0
+let col = 1
+let downwards = 1
+let col_inc = 1
+let initial_speed = 0.2
+let speed = initial_speed
+let accel = 1.1
+let time = 0.1
+
+let countdown = 0
+
+while 1
+ if downwards
+ let speed += time * accel
+ let line += speed
+ else
+ let speed -= time * accel
+ let line -= speed
+ endif
+
+ if line + 3 >= &lines
+ let downwards = 0
+ let speed = speed * 0.8
+ let line = &lines - 3
+ endif
+ if !downwards && speed < 1.0
+ let downwards = 1
+ let speed = initial_speed
+ if line + 4 > &lines && countdown == 0
+ let countdown = 50
+ endif
+ endif
+
+ let col += col_inc
+ if col + 4 >= &columns
+ let col_inc = -1
+ elseif col <= 1
+ let col_inc = 1
+ endif
+
+ call popup_move(winid, {'line': float2nr(line), 'col': col})
+ redraw
+ let framecount += 1
+ if countdown > 0
+ let countdown -= 1
+ if countdown == 0
+ break
+ endif
+ endif
+
+endwhile
+
+let elapsed = reltimefloat(reltime(start))
+echomsg framecount .. ' frames in ' .. string(elapsed) .. ' seconds, ' .. string(framecount / elapsed) .. ' frames/sec'
+
+qa