refact04.gms : Refactor suite test 4

Description

This test is the fourth one of the refactor suite. This is a quantitative test
of writing/reading a workfile with one large parameter.
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 : refact04.gms

$title 'Refactor suite test 4' (REFACT04,SEQ=665)

$onText
This test is the fourth one of the refactor suite. This is a quantitative test
of writing/reading a workfile with one large parameter.
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 > largeParameterW.gms
set i /i1*i1000/;
set j /j1*j1000/;
set k /k1*k10000/;
parameter p(i,j,k) / (#i:#j).#k 1 /;
$offEcho

$onEcho > largeParameterR.gms
set abc;
$offEcho


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

$call gams largeParameterR lo=2 r=largeParameterW
$if errorlevel 1 $abort Problem running largeParameterR

$ifThen set before
$  call grep elapsed largeParameterW.log | tail -1 | cut -f5 -d":" > timeBefore4W.txt
$  call grep elapsed largeParameterR.log | tail -1 | cut -f5 -d":" > timeBefore4R.txt
$else
$  if not exist timeBefore4W.txt $abort Run with --before=True first to get reference workfiles
$  call grep elapsed largeParameterW.log | tail -1 | cut -f5 -d":" > timeAfter4W.txt
$  call grep elapsed largeParameterR.log | tail -1 | cut -f5 -d":" > timeAfter4R.txt
   Scalar beforeW /
$  include timeBefore4W.txt
   /;
   Scalar beforeR /
$  include timeBefore4R.txt
   /;
   Scalar afterW /
$  include timeAfter4W.txt
   /;
   Scalar afterR /
$  include timeAfter4R.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