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
6"    ./vim --clean -S testdir/popupbounce.vim main.c
7"    gprof vim gmon.out | vim -
8
9" using line continuation
10set nocp
11
12" don't switch screens when quitting, so we can read the frames/sec
13set t_te=
14
15let winid = popup_create(['line1', 'line2', 'line3', 'line4'], {
16	      \   'line' : 1,
17	      \   'col' : 1,
18	      \   'zindex' : 101,
19	      \ })
20redraw
21
22let start = reltime()
23let framecount = 0
24
25let line = 1.0
26let col = 1
27let downwards = 1
28let col_inc = 1
29let initial_speed = 0.2
30let speed = initial_speed
31let accel = 1.1
32let time = 0.1
33
34let countdown = 0
35
36while 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
75endwhile
76
77let elapsed = reltimefloat(reltime(start))
78echomsg framecount .. ' frames in ' .. string(elapsed) .. ' seconds, ' .. string(framecount / elapsed) .. ' frames/sec'
79
80qa
81