Skip to content

Commit

Permalink
Simplified implementation of execStat
Browse files Browse the repository at this point in the history
  • Loading branch information
lochel authored and OpenModelica-Hudson committed Sep 30, 2015
1 parent 30fb32e commit 88785c8
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions Compiler/SimCode/SimCodeFunctionUtil.mo
Expand Up @@ -2823,35 +2823,24 @@ public function execStat
consumed by the compiler at this point in time.
"
input String name;
algorithm
execStat2(Flags.isSet(Flags.EXEC_STAT),name);
end execStat;

protected function execStat2
input Boolean cond;
input String name;
algorithm
_ := match (cond,name)
local
Real t,total,used,allocated;
String timeStr,totalTimeStr,gcStr;
case (false,_) then ();
protected
Real t, total;
String timeStr, totalTimeStr, gcStr;
algorithm
if Flags.isSet(Flags.EXEC_STAT) then
t := System.realtimeTock(ClockIndexes.RT_CLOCK_EXECSTAT);
total := System.realtimeTock(ClockIndexes.RT_CLOCK_EXECSTAT_CUMULATIVE);
gcStr := GC.profStatsStr(GC.getProfStats(), head="");
timeStr := System.snprintff("%.4g", 20, t);
totalTimeStr := System.snprintff("%.4g", 20, total);
if Flags.isSet(Flags.GC_PROF) then
Error.addMessage(Error.EXEC_STAT_GC, {name, timeStr, totalTimeStr, gcStr});
else
equation
t = System.realtimeTock(ClockIndexes.RT_CLOCK_EXECSTAT);
total = System.realtimeTock(ClockIndexes.RT_CLOCK_EXECSTAT_CUMULATIVE);
gcStr = GC.profStatsStr(GC.getProfStats(), head="");
timeStr = System.snprintff("%.4g",20,t);
totalTimeStr = System.snprintff("%.4g",20,total);
if Flags.isSet(Flags.GC_PROF) then
Error.addMessage(Error.EXEC_STAT_GC,{name,timeStr,totalTimeStr,gcStr});
else
Error.addMessage(Error.EXEC_STAT,{name,timeStr,totalTimeStr});
end if;
System.realtimeTick(ClockIndexes.RT_CLOCK_EXECSTAT);
then ();
end match;
end execStat2;
Error.addMessage(Error.EXEC_STAT, {name, timeStr, totalTimeStr});
end if;
System.realtimeTick(ClockIndexes.RT_CLOCK_EXECSTAT);
end if;
end execStat;

public function varIndex
input SimCodeVar.SimVar var;
Expand Down

0 comments on commit 88785c8

Please sign in to comment.