Root: IMsCalculationStatNode;
The Root property determines a root node of statistics tree.
Executing the example requires that the repository contains a modeling container with the CONT_MODEL identifier and a modeling problem with the PROBLEM identifier.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
Problem: IMsProblem;
Settings: IMsProblemCalculationSettings;
Calc: IMsProblemCalculation;
Begin
Mb := MetabaseClass.Active;
// Get modeling problem
Problem := Mb.ItemByIdNamespace("PROBLEM", Mb.GetObjectKeyById("CONT_MODEL")).EditTemporary As IMsProblem;
Settings := Problem.CreateCalculationSettings;
// Set calculation statistics drill down
Settings.StatsLevel := MsCalculationStatsLevel.Basic;
Calc := Problem.Calculate(Settings);
// Calculate modeling problem and calculation statistics
Calc.Run;
// Display result in the console
ShowStats(Calc.Stats);
End Sub UserProc;
Sub ShowStats(Stats: IMsCalculationStats);
Var
Node: IMsCalculationStatNode;
Nodes: IMsCalculationStatNodes;
Begin
// Build calculation statistics tree
Node := Stats.Root;
Node.Name := "Calculation statistics:";
Debug.WriteLine(Node.Name);
Nodes := Stats.Root.Children;
For Each Node In Nodes Do
ShowNode(Node);
End For;
End Sub ShowStats;
Sub ShowNode(StatNode: IMsCalculationStatNode);
Var
j: Integer;
Node: IMsCalculationStatNode;
Value: Variant;
Values: Array Of Variant;
Combined: String;
Begin
// Build calculation statistics tree nodes
Debug.Indent;
Debug.Write(StatNode.Name + ": " + StatNode.Id + "; " + StatNode.Type.ToString);
Value := StatNode.Value;
If Value Is Array Then
Values := Value As Array;
For j := 0 To Values.Length - 1 Do
If Not Combined.IsEmpty Then
Combined := Combined + ", ";
End If;
Combined := Combined + Values[j];
End For;
Debug.Write("[" + Combined + "]");
Combined := "";
Elseif Value Is IMsDatePeriod Then
Debug.Write((Value As IMsDatePeriod).Start.ToString + " - " + (Value As IMsDatePeriod).End_.ToString);
Else
Debug.Write("; " + StatNode.Value);
End If;
Debug.WriteLine("");
If StatNode.Children.Count > 0 Then
For Each Node In StatNode.Children Do
ShowNode(Node);
End For;
End If;
Debug.Unindent;
End Sub ShowNode;
After executing the example, the specified modeling problem with the PROBLEM identifier is calculated.
The console displays calculation statistics with identifier, calculation type and value:
Calculation statistics:
Load data: LOADSTEP; 0;
Calculation time (sec): ELAPSEDTIME; 1; 0.094
Statistical data: TSDB_STAT; 0;
External matrix: EXTERNALMATRIX; 0; 0
Number of points: POINTCOUNT; 0; 31
Calculation: CALCSTEP; 0;
Calculation time (sec): ELAPSEDTIME; 1; 0
Multidimensional iterator: ; 0;
Save data: SAVESTEP; 0;
Calculation time (sec): ELAPSEDTIME; 1; 0
Statistical data: TSDB_STAT; 0;
External matrix: EXTERNALMATRIX; 0; 0
Number of points: POINTCOUNT; 0; 31
Number of changed points: CHANGEDPOINTCOUNT; 0; 0
See also: