execution profiler
This commit is contained in:
parent
926a26a724
commit
907de4da7b
2 changed files with 23 additions and 0 deletions
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.client.data.DbLogger;
|
import info.nightscout.client.data.DbLogger;
|
||||||
import info.nightscout.client.data.NSProfile;
|
import info.nightscout.client.data.NSProfile;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
import info.nightscout.utils.Profiler;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
import info.nightscout.utils.ToastUtils;
|
import info.nightscout.utils.ToastUtils;
|
||||||
|
@ -167,6 +168,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
minBg = Round.roundTo(minBg, 0.1d);
|
minBg = Round.roundTo(minBg, 0.1d);
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
|
||||||
|
Date start = new Date();
|
||||||
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments();
|
TreatmentsInterface treatments = MainApp.getConfigBuilder().getActiveTreatments();
|
||||||
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
|
TempBasalsInterface tempBasals = MainApp.getConfigBuilder().getActiveTempBasals();
|
||||||
treatments.updateTotalIOB();
|
treatments.updateTotalIOB();
|
||||||
|
@ -179,6 +181,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
TreatmentsPlugin.MealData mealData = treatments.getMealData();
|
TreatmentsPlugin.MealData mealData = treatments.getMealData();
|
||||||
|
|
||||||
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
|
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
|
||||||
|
Profiler.log(log, "MA data gathering", start);
|
||||||
|
|
||||||
minBg = verifyHardLimits(minBg, "minBg", 72, 180);
|
minBg = verifyHardLimits(minBg, "minBg", 72, 180);
|
||||||
maxBg = verifyHardLimits(maxBg, "maxBg", 100, 270);
|
maxBg = verifyHardLimits(maxBg, "maxBg", 100, 270);
|
||||||
|
@ -193,7 +196,9 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
||||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
||||||
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
if (!checkOnlyHardLimits(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||||
|
|
||||||
|
start = new Date();
|
||||||
determineBasalAdapterJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobTotal, glucoseStatus, mealData);
|
determineBasalAdapterJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobTotal, glucoseStatus, mealData);
|
||||||
|
Profiler.log(log, "MA calculation", start);
|
||||||
|
|
||||||
|
|
||||||
DetermineBasalResult determineBasalResult = determineBasalAdapterJS.invoke();
|
DetermineBasalResult determineBasalResult = determineBasalAdapterJS.invoke();
|
||||||
|
|
18
app/src/main/java/info/nightscout/utils/Profiler.java
Normal file
18
app/src/main/java/info/nightscout/utils/Profiler.java
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package info.nightscout.utils;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by mike on 29.01.2017.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Profiler {
|
||||||
|
public Profiler(){}
|
||||||
|
|
||||||
|
static public void log(Logger log, String function, Date start) {
|
||||||
|
long msec = new Date().getTime() - start.getTime();
|
||||||
|
log.debug(">>> " + function + " <<< executed in " + msec + " miliseconds");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue