01: package org.objectweb.celtix.pat.internal;
02:
03: public class TestResult {
04: public static final String AVG_UNIT = "(ms)";
05: private static final String THROUGHPUT_UNIT = "(invocations/sec)";
06:
07: private String name;
08: private TestCaseBase testCase;
09:
10: private double avgResponseTime;
11: private double throughput;
12:
13: public TestResult() {
14: this ("Default Result");
15: }
16:
17: public TestResult(String cname) {
18: this (cname, null);
19: }
20:
21: public TestResult(String cname, TestCaseBase test) {
22: this .name = cname;
23: this .testCase = test;
24: }
25:
26: public void compute(long startTime, long endTime,
27: int numberOfInvocations) {
28: double numOfInvocations = (double) numberOfInvocations;
29: double duration = convertToSeconds(endTime - startTime);
30:
31: throughput = numOfInvocations / duration;
32: avgResponseTime = duration / numOfInvocations;
33:
34: System.out.println("Throughput: " + testCase.getOperationName()
35: + " " + throughput + THROUGHPUT_UNIT);
36: System.out.println("AVG. response time: " + avgResponseTime
37: * 1000 + AVG_UNIT);
38: System.out.println(numOfInvocations
39: + " (invocations), running " + duration + " (sec) ");
40:
41: }
42:
43: private double convertToSeconds(double ms) {
44: return ms / 1000;
45: }
46:
47: public String getName() {
48: return this .name;
49: }
50:
51: public double getAvgResponseTime() {
52: return avgResponseTime;
53: }
54:
55: public double getThroughput() {
56: return throughput;
57: }
58: }
|