Search in sources :

Example 6 with TimeValue

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());
}
Also used : PrintStream(java.io.PrintStream) DescriptiveStatistics(org.apache.commons.math.stat.descriptive.DescriptiveStatistics) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) TimeValue(alma.acs.algorithms.DataBinner.TimeValue)

Example 7 with TimeValue

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()));
    }
}
Also used : DescriptiveStatistics(org.apache.commons.math.stat.descriptive.DescriptiveStatistics) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) DataBinner(alma.acs.algorithms.DataBinner) ComponentRequest(alma.acs.manager.logparser.ManagerStdoutParser.ComponentRequest) BinnedTimeValues(alma.acs.algorithms.DataBinner.BinnedTimeValues) File(java.io.File) TimeValue(alma.acs.algorithms.DataBinner.TimeValue) Test(org.junit.Test)

Aggregations

TimeValue (alma.acs.algorithms.DataBinner.TimeValue)7 File (java.io.File)6 DataBinner (alma.acs.algorithms.DataBinner)3 BinnedTimeValues (alma.acs.algorithms.DataBinner.BinnedTimeValues)3 PrintStream (java.io.PrintStream)3 DescriptiveStatistics (org.apache.commons.math.stat.descriptive.DescriptiveStatistics)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 ComponentRequest (alma.acs.manager.logparser.ManagerStdoutParser.ComponentRequest)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 DecimalFormat (java.text.DecimalFormat)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1