refact03.gms : Refactor suite test 3

Description

This test is the third one of the refactor suite. This is a quantitative test
of writing/reading a workfile with a large amount of symbols.
There is an expected sequence when using this test:

1. Run this test with command line option "--before=True"
2. Modify and rebuild cmex
3. Run this test without command line option

Contributor: Clemens Westphal, August 2014


Small Model of Type : GAMS


Category : GAMS Test library


Main file : refact03.gms

$title 'Refactor suite test 3' (REFACT03,SEQ=664)

$onText
This test is the third one of the refactor suite. This is a quantitative test
of writing/reading a workfile with a large amount of symbols.
There is an expected sequence when using this test:

1. Run this test with command line option "--before=True"
2. Modify and rebuild cmex
3. Run this test without command line option

Contributor: Clemens Westphal, August 2014
$offText

$onEcho > putDriver.gms
set i /1*100000/;

file f /manySymbolsW.gms/;
put f;
loop(i,
  put 'set s' i.tl:0 '/' i.tl:0 '/;' / ;
  put 'parameter p' i.tl:0 '/' i.tl:0 '/;' / ;
  put 'variable v' i.tl:0 ';' / ;
  put 'equation e' i.tl:0 ';' / ;
);
putclose;
$offEcho

$onEcho > manySymbolsR.gms
set abc;
$offEcho

$call gams putDriver.gms
$if errorlevel 1 $abort Problem running putDriver

$call gams manySymbolsW lo=2 s=manySymbolsW
$if errorlevel 1 $abort Problem running manySymbolsW

$call gams manySymbolsR lo=2 r=manySymbolsW
$if errorlevel 1 $abort Problem running manySymbolsR

$ifThen set before
$  call grep elapsed manySymbolsW.log | tail -1 | cut -f5 -d":" > timeBefore3W.txt
$  call grep elapsed manySymbolsR.log | tail -1 | cut -f5 -d":" > timeBefore3R.txt
$else
$  if not exist timeBefore3W.txt $abort Run with --before=True first to get reference workfiles
$  call grep elapsed manySymbolsW.log | tail -1 | cut -f5 -d":" > timeAfter3W.txt
$  call grep elapsed manySymbolsR.log | tail -1 | cut -f5 -d":" > timeAfter3R.txt
   Scalar beforeW /
$  include timeBefore3W.txt
   /;
   Scalar beforeR /
$  include timeBefore3R.txt
   /;
   Scalar afterW /
$  include timeAfter3W.txt
   /;
   Scalar afterR /
$  include timeAfter3R.txt
   /;
   Scalar UnexpDiffW /[abs(beforeW-afterW)/max(beforeW,afterW)>0.05]/;
   Scalar UnexpDiffR /[abs(beforeR-afterR)/max(beforeR,afterR)>0.05]/;

   Display 'Timing results for writing:', beforeW, afterW;
   Display 'Timing results for reading:', beforeR, afterR;
   Display$UnexpDiffW '*** Unexpected time difference between before and after (writing)'
   Display$UnexpDiffR '*** Unexpected time difference between before and after (reading)'
   abort$[UnexpDiffW or UnexpDiffR] '*** Unexpected time difference between before and after:';
$endIf