FCSys.Utilities.Time

Functions to check translation time

Information

Extends from Modelica.Icons.Package (Icon for standard packages).

Package Content

NameDescription
FCSys.Utilities.Time.get_time get_time Return the current time
FCSys.Utilities.Time.timeTranslation timeTranslation Print the time required to translate a model

FCSys.Utilities.Time.get_time FCSys.Utilities.Time.get_time

Return the current time

Information

Extends from Modelica.Icons.Function (Icon for functions).

Outputs

TypeNameDescription
IntegertTime in milliseconds since January 1, 1970

Modelica definition

function get_time "Return the current time"
  extends Modelica.Icons.Function;

  output Integer t "Time in milliseconds since January 1, 1970";

external"C";
  // Note:  Since Dymola 7.4 doesn't support the IncludeDirectory annotation,
  // it will be necessary to use the full
  // path in the Include annotation, e.g.
  //   Include="#include \"FCSys/FCSys 2.0/Resources/Source/C/time.c\""

end get_time;

FCSys.Utilities.Time.timeTranslation FCSys.Utilities.Time.timeTranslation

Print the time required to translate a model

Information

The time is rounded down to the integer second.

Extends from Modelica.Icons.Function (Icon for functions).

Inputs

TypeNameDefaultDescription
Stringproblem Path and name of the model (with modifiers, if any)
StringfileName"translg.txt"File where to print (empty string is the terminal)

Outputs

TypeNameDescription
Booleanoktrue if successful

Modelica definition

function timeTranslation 
  "Print the time required to translate a model"
  extends Modelica.Icons.Function;
  import Modelica.Utilities.Streams.print;

  input String problem "Path and name of the model (with modifiers, if any)";
  input String fileName="translg.txt" 
    "File where to print (empty string is the terminal)";
  output Boolean ok "true if successful";

protected 
  Integer t_0 "Start time in seconds";

algorithm 
  if fileName <> "" then
    Modelica.Utilities.Files.remove(fileName);
  end if;

  t_0 := get_time();
  ok := translateModel(problem);
  print("Translation time: " + String(get_time() - t_0) + " s", fileName);

end timeTranslation;