@Test public void calculateThroughput_PacketListIsNull(){ List<PacketInfo> packets = new ArrayList<PacketInfo>(); List<Throughput> testResult = new ArrayList<Throughput>(); testResult = throughputCalculator.calculateThroughput(0.0, 0.0, 0.0, packets); assertEquals(true,testResult.isEmpty()); }
public List<Throughput> calculateThroughput(double startTime, double endTime, double window, List<PacketInfo> packets) { List<Throughput> result = new ArrayList<Throughput>(); List<PacketInfo> split = new ArrayList<>(); if(window < 0.00001 || endTime-startTime < 0.00001) { return Collections.emptyList(); } double splitStart = startTime; double splitEnd = startTime + window; for (PacketInfo packet : packets) { double stamp = packet.getTimeStamp(); if (stamp < startTime) { continue; } else if (stamp >= endTime) { result.add(getThroughput(splitStart, splitEnd, split)); break; } else if (stamp >= splitEnd) { while (stamp >= splitEnd) { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } split.add(packet); } else if (stamp >= splitStart) { split.add(packet); } } do { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } while (endTime >= splitStart); return result; }
ThroughputCalculatorImpl implements IThroughputCalculator { public List<Throughput> calculateThroughput(double startTime, double endTime, double window, List<PacketInfo> packets) { List<Throughput> result = new ArrayList<Throughput>(); List<PacketInfo> split = new ArrayList<>(); if(window < 0.00001 || endTime-startTime < 0.00001) { return Collections.emptyList(); } double splitStart = startTime; double splitEnd = startTime + window; for (PacketInfo packet : packets) { double stamp = packet.getTimeStamp(); if (stamp < startTime) { continue; } else if (stamp >= endTime) { result.add(getThroughput(splitStart, splitEnd, split)); break; } else if (stamp >= splitEnd) { while (stamp >= splitEnd) { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } split.add(packet); } else if (stamp >= splitStart) { split.add(packet); } } do { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } while (endTime >= splitStart); return result; } }
ThroughputCalculatorImpl implements IThroughputCalculator { public List<Throughput> calculateThroughput(double startTime, double endTime, double window, List<PacketInfo> packets) { List<Throughput> result = new ArrayList<Throughput>(); List<PacketInfo> split = new ArrayList<>(); if(window < 0.00001 || endTime-startTime < 0.00001) { return Collections.emptyList(); } double splitStart = startTime; double splitEnd = startTime + window; for (PacketInfo packet : packets) { double stamp = packet.getTimeStamp(); if (stamp < startTime) { continue; } else if (stamp >= endTime) { result.add(getThroughput(splitStart, splitEnd, split)); break; } else if (stamp >= splitEnd) { while (stamp >= splitEnd) { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } split.add(packet); } else if (stamp >= splitStart) { split.add(packet); } } do { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } while (endTime >= splitStart); return result; }  }
ThroughputCalculatorImpl implements IThroughputCalculator { public List<Throughput> calculateThroughput(double startTime, double endTime, double window, List<PacketInfo> packets) { List<Throughput> result = new ArrayList<Throughput>(); List<PacketInfo> split = new ArrayList<>(); if(window < 0.00001 || endTime-startTime < 0.00001) { return Collections.emptyList(); } double splitStart = startTime; double splitEnd = startTime + window; for (PacketInfo packet : packets) { double stamp = packet.getTimeStamp(); if (stamp < startTime) { continue; } else if (stamp >= endTime) { result.add(getThroughput(splitStart, splitEnd, split)); break; } else if (stamp >= splitEnd) { while (stamp >= splitEnd) { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } split.add(packet); } else if (stamp >= splitStart) { split.add(packet); } } do { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } while (endTime >= splitStart); return result; }  List<Throughput> calculateThroughput(double startTime, double endTime, double window,
			List<PacketInfo> packets); }
ThroughputCalculatorImpl implements IThroughputCalculator { public List<Throughput> calculateThroughput(double startTime, double endTime, double window, List<PacketInfo> packets) { List<Throughput> result = new ArrayList<Throughput>(); List<PacketInfo> split = new ArrayList<>(); if(window < 0.00001 || endTime-startTime < 0.00001) { return Collections.emptyList(); } double splitStart = startTime; double splitEnd = startTime + window; for (PacketInfo packet : packets) { double stamp = packet.getTimeStamp(); if (stamp < startTime) { continue; } else if (stamp >= endTime) { result.add(getThroughput(splitStart, splitEnd, split)); break; } else if (stamp >= splitEnd) { while (stamp >= splitEnd) { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } split.add(packet); } else if (stamp >= splitStart) { split.add(packet); } } do { result.add(getThroughput(splitStart, splitEnd, split)); splitStart = splitEnd; splitEnd = splitStart + window; split = new ArrayList<>(); } while (endTime >= splitStart); return result; }  List<Throughput> calculateThroughput(double startTime, double endTime, double window,
			List<PacketInfo> packets);  }