Bram Moolenaar | 4c063a0 | 2019-06-10 21:24:12 +0200 | [diff] [blame] | 1 | " Use this script to measure the redrawing performance when a popup is being |
| 2 | " displayed. Usage with gcc: |
| 3 | " cd src |
| 4 | " # Edit Makefile to uncomment PROFILE_CFLAGS and PROFILE_LIBS |
| 5 | " make reconfig |
Christian Brabandt | eb380b9 | 2025-07-07 20:53:55 +0200 | [diff] [blame] | 6 | " ./vim --clean -S testdir/util/popupbounce.vim main.c |
Bram Moolenaar | 4c063a0 | 2019-06-10 21:24:12 +0200 | [diff] [blame] | 7 | " gprof vim gmon.out | vim - |
| 8 | |
Bram Moolenaar | 1bc353b | 2019-09-01 14:45:28 +0200 | [diff] [blame] | 9 | " using line continuation |
Bram Moolenaar | 4c063a0 | 2019-06-10 21:24:12 +0200 | [diff] [blame] | 10 | set nocp |
| 11 | |
| 12 | " don't switch screens when quitting, so we can read the frames/sec |
| 13 | set t_te= |
| 14 | |
| 15 | let winid = popup_create(['line1', 'line2', 'line3', 'line4'], { |
| 16 | \ 'line' : 1, |
| 17 | \ 'col' : 1, |
| 18 | \ 'zindex' : 101, |
| 19 | \ }) |
| 20 | redraw |
| 21 | |
| 22 | let start = reltime() |
| 23 | let framecount = 0 |
| 24 | |
| 25 | let line = 1.0 |
| 26 | let col = 1 |
| 27 | let downwards = 1 |
| 28 | let col_inc = 1 |
| 29 | let initial_speed = 0.2 |
| 30 | let speed = initial_speed |
| 31 | let accel = 1.1 |
| 32 | let time = 0.1 |
| 33 | |
| 34 | let countdown = 0 |
| 35 | |
| 36 | while 1 |
| 37 | if downwards |
| 38 | let speed += time * accel |
| 39 | let line += speed |
| 40 | else |
| 41 | let speed -= time * accel |
| 42 | let line -= speed |
| 43 | endif |
| 44 | |
| 45 | if line + 3 >= &lines |
| 46 | let downwards = 0 |
| 47 | let speed = speed * 0.8 |
| 48 | let line = &lines - 3 |
| 49 | endif |
| 50 | if !downwards && speed < 1.0 |
| 51 | let downwards = 1 |
| 52 | let speed = initial_speed |
| 53 | if line + 4 > &lines && countdown == 0 |
| 54 | let countdown = 50 |
| 55 | endif |
| 56 | endif |
| 57 | |
| 58 | let col += col_inc |
| 59 | if col + 4 >= &columns |
| 60 | let col_inc = -1 |
| 61 | elseif col <= 1 |
| 62 | let col_inc = 1 |
| 63 | endif |
| 64 | |
| 65 | call popup_move(winid, {'line': float2nr(line), 'col': col}) |
| 66 | redraw |
| 67 | let framecount += 1 |
| 68 | if countdown > 0 |
| 69 | let countdown -= 1 |
| 70 | if countdown == 0 |
| 71 | break |
| 72 | endif |
| 73 | endif |
| 74 | |
| 75 | endwhile |
| 76 | |
| 77 | let elapsed = reltimefloat(reltime(start)) |
| 78 | echomsg framecount .. ' frames in ' .. string(elapsed) .. ' seconds, ' .. string(framecount / elapsed) .. ' frames/sec' |
| 79 | |
| 80 | qa |