Search in sources :

Example 1 with TimeValue

use of alma.acs.algorithms.DataBinner.TimeValue in project ACS by ACS-Community.

the class CdbCallStatistics method getDaoCallsWithParameter.

/**
	 * Work in progress, not used yet.
	 */
public void getDaoCallsWithParameter() throws IOException {
    OrbProfilerStatistics stat = new OrbProfilerStatistics(messages, logger);
    List<TimeValue<Integer>> calls = stat.getFinishedRequests("get_DAO");
    BufferedReader reader = new BufferedReader(new FileReader(dataFile));
    String line = null;
    while ((line = reader.readLine()) != null) {
        int pos = line.indexOf("Returning XML record for:");
        if (pos > 0) {
            String xmlRecordPath = line.substring(pos + "Returning XML record for: ".length());
            System.out.println(xmlRecordPath);
        // TODO: deal with call and stack
        }
    }
    reader.close();
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) TimeValue(alma.acs.algorithms.DataBinner.TimeValue)

Example 2 with TimeValue

use of alma.acs.algorithms.DataBinner.TimeValue in project ACS by ACS-Community.

the class CdbCallStatistics method getConcurrentCalls.

/**
	 * Produces a list of timestamps and the number of concurrent calls at that time.
	 */
public void getConcurrentCalls() throws FileNotFoundException {
    OrbProfilerStatistics stat = new OrbProfilerStatistics(messages, logger);
    List<TimeValue<Integer>> concCalls = stat.getConcurrentCalls();
    File outFile = new File(getFileNameBase() + "_concurrentCallCount.txt");
    PrintStream pr = new PrintStream(outFile);
    pr.println("time" + delim + "# concurrent calls");
    for (TimeValue<Integer> timeValue : concCalls) {
        pr.println(timeString(timeValue.timeMillis) + delim + timeValue.value);
    }
    pr.close();
    logger.info("Wrote " + outFile.getAbsolutePath());
}
Also used : PrintStream(java.io.PrintStream) File(java.io.File) TimeValue(alma.acs.algorithms.DataBinner.TimeValue)

Example 3 with TimeValue

use of alma.acs.algorithms.DataBinner.TimeValue in project ACS by ACS-Community.

the class OrbProfilerStatisticsTest method testConcurrentCalls.

@Test
public void testConcurrentCalls() throws Exception {
    OrbProfilerParser parser = new OrbProfilerParser(logger);
    List<ProfilerMessage> messages = parser.parse(new File("hibernateCdbJDal-2011-09-12T153856.txt"));
    Collections.sort(messages);
    //		for (int i = 0; i < 100; i++) {
    //			ProfilerMessage msg = messages.get(i);
    //			System.out.println(timeString(msg.timestamp) + "\t" + msg.type.name()  + "\t" + msg.operation);
    //		}
    OrbProfilerStatistics stat = new OrbProfilerStatistics(messages, logger);
    List<TimeValue<Integer>> concCalls = stat.getConcurrentCalls();
// todo: evaluate, output etc
}
Also used : File(java.io.File) TimeValue(alma.acs.algorithms.DataBinner.TimeValue) Test(org.junit.Test)

Example 4 with TimeValue

use of alma.acs.algorithms.DataBinner.TimeValue in project ACS by ACS-Community.

the class OrbProfilerStatisticsTest method testFinishedRequestBinning.

@Test
public void testFinishedRequestBinning() throws Exception {
    OrbProfilerParser parser = new OrbProfilerParser(logger);
    List<ProfilerMessage> messages = parser.parse(new File("hibernateCdbJDal-2011-09-12T153856.txt"));
    OrbProfilerStatistics stat = new OrbProfilerStatistics(messages, logger);
    List<TimeValue<Integer>> callsGetDao = stat.getFinishedRequests("get_DAO");
    assertEquals(8415, callsGetDao.size());
    //		System.out.println("*** Last 10 get_DAO calls with response times in ms ***");
    //		for (int i = callsGetDao.size()-11; i < callsGetDao.size(); i++) {
    //			TimeValue call = callsGetDao.get(i);
    //			System.out.println(timeString(call.timeMillis) + "\t(=" + call.timeMillis + ")\t" + call.value);
    //		}
    final int binIntervalMillis = 1000;
    DataBinner binner = new DataBinner();
    List<BinnedTimeValues<Integer>> binnedData = binner.binTimedData(callsGetDao, binIntervalMillis);
    //		System.out.println("*** Binned get_DAO calls per " + binIntervalMillis + " ms ***");
    //		for (BinnedTimeValues binnedTimeValues : binnedData) {
    //			// todo Calculate max or average
    //			String msg = timeString(binnedTimeValues.timeMillis) + '\t' + binnedTimeValues.binnedData.size(); // + '\t' + binnedTimeValues.binnedData;
    //			System.out.println(msg);
    //		}
    // 4281 one-second bins
    assertEquals(4281, binnedData.size());
    // center time of first bin
    assertEquals("2011-09-12T15:40:47.500", timeString(binnedData.get(0).timeMillis));
    // first bin must have 3 calls
    assertEquals(3, binnedData.get(0).binnedData.size());
    // first call in first bin
    assertEquals("2011-09-12T15:40:47.605", timeString(binnedData.get(0).binnedData.get(0).timeMillis));
    // center time of second bin
    assertEquals("2011-09-12T15:40:48.500", timeString(binnedData.get(1).timeMillis));
    // second bin must have 4 calls
    assertEquals(4, binnedData.get(1).binnedData.size());
    // center time of third bin
    assertEquals("2011-09-12T15:40:49.500", timeString(binnedData.get(2).timeMillis));
    // third bin must be empty
    assertEquals(0, binnedData.get(2).binnedData.size());
}
Also used : BinnedTimeValues(alma.acs.algorithms.DataBinner.BinnedTimeValues) File(java.io.File) TimeValue(alma.acs.algorithms.DataBinner.TimeValue) DataBinner(alma.acs.algorithms.DataBinner) Test(org.junit.Test)

Example 5 with TimeValue

use of alma.acs.algorithms.DataBinner.TimeValue in project ACS by ACS-Community.

the class CdbCallStatistics method getCallFrequency.

/**
	 * @param operationName Can be null, to use calls to all operations.
	 */
public void getCallFrequency(String operationName) throws FileNotFoundException {
    OrbProfilerStatistics stat = new OrbProfilerStatistics(messages, logger);
    final int binIntervalMillis = 1000;
    List<TimeValue<Integer>> allCalls = stat.getFinishedRequests(operationName);
    Collections.sort(allCalls);
    DataBinner binner = new DataBinner();
    List<BinnedTimeValues<Integer>> binnedAllCalls = binner.binTimedData(allCalls, binIntervalMillis);
    String outFileName = getFileNameBase() + "_callFrequency" + (operationName != null ? operationName : "") + ".txt";
    File outFile = new File(outFileName);
    PrintStream pr = new PrintStream(outFile);
    pr.println("time" + delim + "#calls/s" + delim + "duration max" + delim + "duration average");
    for (BinnedTimeValues<Integer> binnedTimeValues : binnedAllCalls) {
        List<TimeValue<Integer>> timeValuesPerBin = binnedTimeValues.binnedData;
        DescriptiveStatistics callTimeStats = new DescriptiveStatistics();
        for (TimeValue<Integer> timeValue : timeValuesPerBin) {
            callTimeStats.addValue(timeValue.value);
        }
        // or timeValuesPerBin.size();
        long numCallsPerBin = callTimeStats.getN();
        pr.println(timeString(binnedTimeValues.timeMillis) + delim + numCallsPerBin + delim + (numCallsPerBin > 0 ? df2.format(callTimeStats.getMax()) : 0) + delim + (numCallsPerBin > 0 ? df2.format(callTimeStats.getMean()) : 0));
    }
    pr.close();
    logger.info("Wrote " + outFile.getAbsolutePath());
}
Also used : PrintStream(java.io.PrintStream) DescriptiveStatistics(org.apache.commons.math.stat.descriptive.DescriptiveStatistics) DataBinner(alma.acs.algorithms.DataBinner) BinnedTimeValues(alma.acs.algorithms.DataBinner.BinnedTimeValues) File(java.io.File) TimeValue(alma.acs.algorithms.DataBinner.TimeValue)

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