Add parallelization of multiple simulations

This commit is contained in:
Quentin Legot 2023-03-31 08:15:44 +02:00
parent 4c2d0ccf50
commit eece2c1d3a

View File

@ -7,6 +7,8 @@ import fr.ntr.scheduler.Scheduler;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Main {
@ -26,6 +28,7 @@ public class Main {
}
int timeSlotNb = 2;
int subCarrierNb = 100;
try(ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors())) {
for(int i = 2; i <= maximumLoad; i += 2) {
List<User> users = generateUsers(i, timeSlotNb, subCarrierNb);
ResourceBlock[][] frame = new ResourceBlock[timeSlotNb][subCarrierNb];
@ -33,10 +36,10 @@ public class Main {
// Scheduler scheduler = new ProportionalFair(frame, users);
Scheduler scheduler = new RoundRobin(frame, users);
AccessPoint accessPoint = new AccessPoint(scheduler, frame, users, timeSlotNb, subCarrierNb, 0, 50);
accessPoint.startSimulation(numberOfTicks);
executor.submit(() -> accessPoint.startSimulation(numberOfTicks));
}
}
else {
} else {
System.err.println("Please give launch arguments");
System.err.println("gradle run --args=\"<number of ticks> <number of users>\"");
System.exit(1);