use of teetime.framework.performancelogging.StateChange in project TeeTime by teetime-framework.
the class AbstractStage method addState.
private void addState(final StageActivationState stateCode, final long timestamp) {
StateChange state = new StateChange(stateCode, timestamp);
this.states.add(state);
this.lastState = state;
}
use of teetime.framework.performancelogging.StateChange in project TeeTime by teetime-framework.
the class CumulativeActivePassivTime method formatData.
@Override
public String formatData() {
String result = "\n Formating to analyse differences in runtime:\n\n";
result += "name;total time;cumulative blocked time;cumulative active waiting time time;active time\n";
// go through all the stages
for (AbstractStage stage : stages) {
// first add a formated version of their names to the line.
result += formateName(stage);
long earliestTimeStamp = Long.MAX_VALUE;
long latestTimeStamp = Long.MIN_VALUE;
long lastTimeStamp = 0;
StageActivationState lastState = StageActivationState.INITIALIZED;
long cumulativeActiveTime = 0;
long cumulativeActiveWaitingTime = StateStatistics.getActiveWaitingTime(stage);
long cumulativeBlockedTime = 0;
// go through all states of this stage and sum up the active times while counting the number of active timestamp
for (StateChange state : StateStatistics.getStates(stage)) {
long actualTimeStamp = state.getTimeStamp();
// update earliest and latest timeStamp if necessary
if (actualTimeStamp < earliestTimeStamp) {
earliestTimeStamp = actualTimeStamp;
} else if (actualTimeStamp > latestTimeStamp) {
latestTimeStamp = actualTimeStamp;
}
// In the first loop neither lastTimeStamp nor lastState are set. So the next part wouldn't calculate correct.
if (lastState != StageActivationState.INITIALIZED) {
long elapsedTime = actualTimeStamp - lastTimeStamp;
switch(lastState) {
case ACTIVE:
cumulativeActiveTime += elapsedTime;
break;
case BLOCKED:
cumulativeBlockedTime += elapsedTime;
break;
case TERMINATED:
break;
default:
break;
}
}
lastTimeStamp = actualTimeStamp;
lastState = state.getStageActivationState();
}
// The ActiveWaiting time was counted into active time till now. So it it subtracted now.
cumulativeActiveTime -= cumulativeActiveWaitingTime;
result += (latestTimeStamp - earliestTimeStamp) + ";" + cumulativeBlockedTime + ";" + cumulativeActiveWaitingTime + ";" + cumulativeActiveTime;
result += "\n";
}
return result.replace("\n", String.format("%n"));
}
use of teetime.framework.performancelogging.StateChange in project TeeTime by teetime-framework.
the class PercentageOfActiveTime method formatData.
@Override
public String formatData() {
String result = "\n Formating of the data to get percentage of active time:\n\n";
result += "name;% active time\n";
for (AbstractStage stage : stages) {
result += formateName(stage);
boolean lastActive = false;
long lastActiveTimestamp = Long.MAX_VALUE;
long cumulativeActiveTime = 0;
long firstTimestamp = Long.MAX_VALUE;
long lastTimestamp = Long.MIN_VALUE;
for (StateChange state : StateStatistics.getStates(stage)) {
if (state.getTimeStamp() < firstTimestamp) {
firstTimestamp = state.getTimeStamp();
}
if (state.getTimeStamp() > lastTimestamp) {
lastTimestamp = state.getTimeStamp();
}
if (!lastActive && state.getStageActivationState() == StageActivationState.ACTIVE) {
lastActive = true;
lastActiveTimestamp = state.getTimeStamp();
}
if (lastActive && state.getStageActivationState() != StageActivationState.ACTIVE && lastActiveTimestamp != Long.MAX_VALUE) {
lastActive = false;
cumulativeActiveTime += (state.getTimeStamp() - lastActiveTimestamp);
}
}
result += ((double) cumulativeActiveTime / (double) (lastTimestamp - firstTimestamp)) * 100 + "\n";
}
return result.replace("\n", String.format("%n"));
}
use of teetime.framework.performancelogging.StateChange in project TeeTime by teetime-framework.
the class RNTFormating method formatData.
@Override
public String formatData() {
String result = "\n Formating of the data to fit Approach of Roser, Nakano and Tanak:\n\n";
result += "name;Average ActiveTime (ns)\n";
// go through all the stages
for (AbstractStage stage : stages) {
// first add a formated version of their names to the line.
result += formateName(stage);
// will count the number of activeTimes
double counter = 0;
// stores the sum of active time
long cummulativeActiveTime = 0;
// stores the last relevant active time stamp
long lastActiveTimeStamp = 0;
// boolean to remember last state that was processed
boolean lastActive = false;
// go through all states of this stage and sum up the active times while counting the number of active times
for (StateChange state : StateStatistics.getStates(stage)) {
if (state.getStageActivationState() == StageActivationState.ACTIVE && !lastActive) {
lastActiveTimeStamp = state.getTimeStamp();
lastActive = true;
} else {
if (lastActive && lastActiveTimeStamp != 0) {
cummulativeActiveTime += (state.getTimeStamp() - lastActiveTimeStamp);
counter++;
}
lastActive = false;
}
}
// Add formated data to the line
result += // this will help to keep track of the necessary information.
((counter != 0) ? ((long) ((cummulativeActiveTime) / counter)) : cummulativeActiveTime);
result += "\n";
}
return result.replace("\n", String.format("%n"));
}
Aggregations