4369 Rate this article:
No rating

Disable window updates to improve (New) Graphics performance

When making a visualization with many graphic elements in NG, you can improve the render speed by disabling updates to the window. For example, this program displays a 3-by-5 grid of sample plots and prints to the console the time taken in doing so:
pro grid3by5
   compile_opt idl2

   n_rows = 5
   n_cols = 3

   start_time = systime(/seconds)

   w = window(dimensions=[500,700])
   ;w.refresh, /disable
   for i=1, n_rows*n_cols do $
      !null = plot(/test, layout=[n_cols, n_rows, i], color=!color.(i), /current)

   end_time = systime(/seconds)
   print, 'Time elapsed (s): ', end_time – start_time
Here’s the console output from running this program on my laptop:
IDL> grid3by5
Time elapsed (s):        6.6850002
Note that you can also see the individual plots being rendered to the window, one after another. (I find this a little distracting.) Now uncomment the calls to disable and re-enable the NG Refresh method in GRID3BY5. This turns off intermediate updates to the window. After recompiling, here’s the console output from running the program:
IDL> grid3by5
Time elapsed (s):        3.4670000
That’s faster! Plus, you don’t see the individual plots being rendered to the window. Depending on what and how many graphic elements are in your visualization, you may see more or less of a performance boost, but speedups of a factor of two are not uncommon.