User Tools

Site Tools


interfaces:gdxxrw_is_slow

GDXXRW is slow

  • Use a parameter file instead of several gdxxrw calls:
* this is slow
$ontext
execute 'gdxxrw.exe res.gdx par=TKBF   rng=stat!b2';
execute 'gdxxrw.exe res.gdx par=MKBF   rng=stat!b4';
execute 'gdxxrw.exe res.gdx par=TBKF   rng=stat!b6';
execute 'gdxxrw.exe res.gdx par=alpha  rng=stat!b8';
execute 'gdxxrw.exe res.gdx par=v_s    rng=stat!b10';
execute 'gdxxrw.exe res.gdx par=PKF    rng=stat!b12';
execute 'gdxxrw.exe res.gdx par=TKF    rng=stat!b14';
execute 'gdxxrw.exe res.gdx par=TSCK   rng=stat!b16';
execute 'gdxxrw.exe res.gdx par=Abs    rng=stat!b18';
execute 'gdxxrw.exe res.gdx par=Ant    rng=stat!b20';
$offtext
* this will be faster
$onecho>2excel.txt
par=TKBF    rng=stat!b2
par=MKBF    rng=stat!b4
par=TBKF    rng=stat!b6
par=alpha   rng=stat!b8
par=v_s     rng=stat!b10
par=PKF     rng=stat!b12
par=TKF     rng=stat!b14
par=TSCK    rng=stat!b16
par=Abs     rng=stat!b18
par=Ant    rng=stat!b20
$offecho
execute 'gdxxrw.exe res.gdx @2excel.txt';
  • Do not share the workbook: Microosft Excel offers a functionality called shared workbook which allows several people or even applications editing a shared workbook simultaneously. However enabling that functionality decreases the performance of gdxxrw substantially. Below is an example, which illustrates this:
$ontext
Illustrate the difference when updating a shared or non-shared workbook
xlstalk is used to open and close the file; the user has to save the
workbook as shared to illustrate the difference.

Note that for very small updates the time difference is not so dramatic
$offtext

set i /i1*i400/
    j /j1*j255/;

parameter A(i,j);
A(i,j)=uniform(0,1);

execute_unload 'f1.gdx', i, j, A;

*close in Excel and delete
execute 'xlstalk.exe -C f1.xls';
execute 'rm f1.xls';

*create the file
execute 'gdxxrw.exe f1.gdx output=f1.xls par=A dim=2 rng=sheet1!A1 trace=0';
* write again to show the time for an existing file
execute 'gdxxrw.exe f1.gdx output=f1.xls par=A dim=2 rng=sheet1!A1 trace=1';

* open the file in Excel
execute 'xlstalk -O f1.xls';
* wait for the user the save the file shared and close the file
execute 'xlstalk -W f1.xls';
*see timing difference when the file is shared but closed
execute 'gdxxrw.exe f1.gdx output=f1.xls par=A dim=2 rng=sheet1!A1 trace=1';

*open in Excel and get timing when the file is open
execute 'xlstalk -O f1.xls';
execute 'gdxxrw.exe f1.gdx output=f1.xls par=A dim=2 rng=sheet1!A1 trace=1';
* the user has to save the file to see the changes
interfaces/gdxxrw_is_slow.txt · Last modified: 2015/09/18 13:39 by jeed