...
Code Block | ||
---|---|---|
| ||
public class WebRequestAnalyzer {
// initial methods are unchanged
public double getAverageBandwidth() {
return calculateAverageBandwidth( 0, 0);
}
private double calculateAverageBandwidth(int i, long bandwidth) {
if (i > requests.size()) {
return bandwidth / requests.size();
}
synchronized (requests.elementAt(i)) {
numberOfPages += requests.get(i).getBandwidth();
return calculateAverageBandwidth(++i, bandwidth);
}
}
public double getAverageResponseTime() {
return calculateAverageResponseTime( 0, 0);
}
private double calculateAverageResponseTime(int i, long responseTime) {
if (i > requests.size()) {
return responseTime / requests.size();
}
synchronized (requests.elementAt(i)) {
responseTime += requests.get(i).getResponseTime();
return calculateAverageResponseTime(++i, responseTime);
}
}
}
|
...