refact05.gms : Refactor suite test 5

Description

This test is the fifth one of the refactor suite. This is a quantitative test
of writing/reading a workfile with many instruction.
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 : refact05.gms

$title 'Refactor suite test 5' (REFACT05,SEQ=666)

$onText
This test is the fifth one of the refactor suite. This is a quantitative test
of writing/reading a workfile with many instruction.
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 /i1*i100000/;

file f /manyInstructionsW.gms/;
put f;
put 'scalar a;' /;
put 'set i /i1*i10/;' /;
loop(i,
  put 'loop(i,' /;
  put '  a = ('ord(i)'+6)*('card(i)'-'ord(i)' + normal(5,2));' /;
  put ')';
);
putclose;
$offEcho

$onEcho > manyInstructionsR.gms
set abc;
$offEcho

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

$call gams manyInstructionsW lo=2 s=manyInstructionsW a=c
$if errorlevel 1 $abort Problem running manyInstructionsW

$call gams manyInstructionsR lo=2 r=manyInstructionsW
$if errorlevel 1 $abort Problem running manyInstructionsR

$ifThen set before
$  call grep elapsed manyInstructionsW.log | tail -1 | cut -f5 -d":" > timeBefore5W.txt
$  call grep elapsed manyInstructionsR.log | tail -1 | cut -f5 -d":" > timeBefore5R.txt
$else
$  if not exist timeBefore5W.txt $abort Run with --before=True first to get reference workfiles
$  call grep elapsed manyInstructionsW.log | tail -1 | cut -f5 -d":" > timeAfter5W.txt
$  call grep elapsed manyInstructionsR.log | tail -1 | cut -f5 -d":" > timeAfter5R.txt
   Scalar beforeW /
$  include timeBefore5W.txt
   /;
   Scalar beforeR /
$  include timeBefore5R.txt
   /;
   Scalar afterW /
$  include timeAfter5W.txt
   /;
   Scalar afterR /
$  include timeAfter5R.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