Map<String,Integer> supps = new HashMap<>();
System.out.println("getQuantityBySupplier");
System.out.println("times");
ViewResult result = null;
for(int i=0;i<10;++i){
long st = System.nanoTime();
result = or.productsWithQuantity();
for (ViewResult.Row row : result.getRows()) {
for(Product p : allProd) {
if(row.getKey().equals(p.getProductID())) {
if(supps.containsKey(p.getSupplierID())) {
int quantity = supps.get(p.getSupplierID());
quantity += Integer.parseInt(row.getValue());
supps.put(p.getSupplierID(), quantity);
break;
} else {
supps.put(p.getSupplierID(), Integer.parseInt(row.getValue()));
}
}
}
}
System.out.print(((System.nanoTime()-st)/1000000.0)+";");
}
System.out.println(allProd.size());
System.out.println(result.getSize());
for(String supp : supps.keySet()) {
System.out.println("SupplierId: "+supp+" , quantity: "+supps.get(supp));
}
}