Commit 43aed510 authored by NewbieOrange's avatar NewbieOrange
Browse files

Make drop course multi-threaded to accelerate benchmark

parent ab110fcd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ Test drop enrolled course 1 time: 0.08s
Import student courses
Import student courses time: 10.21s
Test drop course: 88343
Test drop course time: 75.15s
Test drop course time: 7.08s
Test course table 2: 100
Test course table 2 time: 0.27s
Test search course 2: 500
+5 −5
Original line number Diff line number Diff line
@@ -147,11 +147,11 @@ public final class ProjectJudge {

    public int testDropCourses(Map<String, Map<String, Grade>> studentCourses) {
        AtomicInteger passCount = new AtomicInteger();
        studentCourses.forEach((studentId, grades) -> {
            int student = Integer.parseInt(studentId);
            grades.forEach((sectionId, grade) -> {
                if (grade != null) {
                    int section = importer.mapSectionId(Integer.parseInt(sectionId));
        studentCourses.entrySet().parallelStream().forEach(grades -> {
            int student = Integer.parseInt(grades.getKey());
            grades.getValue().entrySet().parallelStream().forEach(it -> {
                if (it.getValue() != null) {
                    int section = importer.mapSectionId(Integer.parseInt(it.getKey()));
                    try {
                        studentService.dropCourse(student, section);
                    } catch (IllegalStateException e) {