use of alma.acs.algorithms.DataBinner.TimeValue in project ACS by ACS-Community.
the class CdbCallStatistics method getCallTimeByMethodGroup.
public void getCallTimeByMethodGroup() throws IOException {
OrbProfilerStatistics stat = new OrbProfilerStatistics(messages, logger);
Map<String, List<TimeValue<Integer>>> callGroups = new LinkedHashMap<String, List<TimeValue<Integer>>>();
// Corba object methods (TODO: add others)
callGroups.put("_is_a", stat.getFinishedRequests("_is_a"));
// methods for CDB change listening
List<TimeValue<Integer>> listenerCalls = new ArrayList<TimeValue<Integer>>();
listenerCalls.addAll(stat.getFinishedRequests("add_change_listener"));
listenerCalls.addAll(stat.getFinishedRequests("remove_change_listener"));
listenerCalls.addAll(stat.getFinishedRequests("listen_for_changes"));
Collections.sort(listenerCalls);
callGroups.put("listener methods", listenerCalls);
// the hefty XML requests
callGroups.put("get_DAO", stat.getFinishedRequests("get_DAO"));
// calls to a DAO remote object
List<TimeValue<Integer>> daoCalls = new ArrayList<TimeValue<Integer>>();
daoCalls.addAll(stat.getFinishedRequests("get_long"));
daoCalls.addAll(stat.getFinishedRequests("get_double"));
daoCalls.addAll(stat.getFinishedRequests("get_string"));
daoCalls.addAll(stat.getFinishedRequests("get_field_data"));
daoCalls.addAll(stat.getFinishedRequests("get_string_seq"));
daoCalls.addAll(stat.getFinishedRequests("get_long_seq"));
daoCalls.addAll(stat.getFinishedRequests("get_double_seq"));
daoCalls.addAll(stat.getFinishedRequests("destroy"));
Collections.sort(daoCalls);
callGroups.put("daoCalls", daoCalls);
// returns a DAO remote object
callGroups.put("get_DAO_Servant ", stat.getFinishedRequests("get_DAO_Servant"));
// listing of available nodes
List<TimeValue<Integer>> listingCalls = new ArrayList<TimeValue<Integer>>();
listingCalls.addAll(stat.getFinishedRequests("list_nodes"));
listingCalls.addAll(stat.getFinishedRequests("list_daos"));
Collections.sort(listingCalls);
callGroups.put("list methods", listingCalls);
// todo: Also use WDAL, WDAO methods
File outFile = new File(getFileNameBase() + "_callTimeByMethodGroup.txt");
PrintStream pr = new PrintStream(outFile);
pr.println("rdbCDB operation" + delim + "# calls" + delim + "average [ms]" + delim + "max(100%) [ms]" + delim + "max(99%) [ms]" + delim + "stdev [ms]");
for (String groupName : callGroups.keySet()) {
List<TimeValue<Integer>> calls = callGroups.get(groupName);
// call duration statistics
DescriptiveStatistics callTimeStats = new DescriptiveStatistics();
for (TimeValue<Integer> timeValue : calls) {
callTimeStats.addValue(timeValue.value);
}
pr.println(groupName + delim + calls.size() + delim + df2.format(callTimeStats.getMean()) + delim + (int) callTimeStats.getMax() + delim + (int) callTimeStats.getPercentile(99) + delim + df2.format(callTimeStats.getStandardDeviation()));
}
pr.close();
logger.info("Wrote " + outFile.getAbsolutePath());
}
use of alma.acs.algorithms.DataBinner.TimeValue in project ACS by ACS-Community.
the class ManagerStdoutParserTest method testParseManagerOutput.
@Test
public void testParseManagerOutput() throws Exception, ParseException {
String fileName = "sampleOutput/acsManager_2012-03-20_16.48.20.642";
ManagerStdoutParser parser = new ManagerStdoutParser(logger);
List<ComponentRequest> requests = parser.parse(new File(fileName));
// to select only logs between these two timestamps
long t0 = IsoDateFormat.parseIsoTimestamp("2011-11-13T20:47:17.328").getTime();
long t1 = IsoDateFormat.parseIsoTimestamp("2011-11-13T21:29:48.314").getTime();
List<TimeValue<ComponentRequest>> data = new ArrayList<TimeValue<ComponentRequest>>();
for (ComponentRequest r : requests) {
// if (r.timeRequested >= t0 && r.timeRequested <= t1) {
data.add(new TimeValue<ComponentRequest>(r.timeRequested, r));
System.out.println(toISO(r.timeRequested) + ", " + (r.timeProvided - r.timeRequested) + ", " + r.key.curl.substring(8) + ", " + r.key.clientName);
// }
}
Collections.sort(data);
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
int binIntervalSec = 5;
DataBinner binner = new DataBinner();
List<BinnedTimeValues<ComponentRequest>> binned = binner.binTimedData(data, binIntervalSec * 1000);
// System.out.println("Time interval\t#Requests by 'Python Client'/" + binIntervalSec +
// "s\t#Requests by other clients/" + binIntervalSec + "s" + "\t" + "Average response time/ms");
System.out.println("Time interval\t#Requests/" + binIntervalSec + "s interval\tAverage response time/ms");
for (BinnedTimeValues<ComponentRequest> binnedTimeValues : binned) {
long timeCurrentBin = binnedTimeValues.timeMillis;
List<TimeValue<ComponentRequest>> valuesCurrentBin = binnedTimeValues.binnedData;
int numCallsPythonClient = 0;
int numCallsOtherClients = 0;
DescriptiveStatistics callTimeStats = new DescriptiveStatistics();
for (TimeValue<ComponentRequest> timeValue : valuesCurrentBin) {
ComponentRequest r = timeValue.value;
if (r.key.clientName.equals("Python Client")) {
numCallsPythonClient++;
} else {
numCallsOtherClients++;
}
// duration in ms
callTimeStats.addValue(r.timeProvided - r.timeRequested);
}
System.out.println(toISO(timeCurrentBin) + "\t" + (numCallsPythonClient + numCallsOtherClients) + "\t" + df.format(callTimeStats.getMean()));
}
}
Aggregations