into advc
This commit is contained in:
hehihoho3@gmail.com 2024-11-28 11:42:26 +09:00
commit 07877fd70a

View File

@ -4176,39 +4176,62 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
// int instCnt = mjonMsgDataDAO.insertMsgDataInfo_advc(mjonMsgSendVOList); // int instCnt = mjonMsgDataDAO.insertMsgDataInfo_advc(mjonMsgSendVOList);
// int instCnt = mjonMsgDataDAO.insertMsgDataInfo_jdbc_advc(mjonMsgSendVOList); // int instCnt = mjonMsgDataDAO.insertMsgDataInfo_jdbc_advc(mjonMsgSendVOList);
// 시작 시간 측정 // 시작 시간 측정
long startTime = System.currentTimeMillis(); long totalStartTime = System.currentTimeMillis();
int totalSize = mjonMsgSendVOList.size(); // 데이터 개수 int totalSize = mjonMsgSendVOList.size(); // 데이터 개수
int batchSize = (int) Math.ceil((double) totalSize / 3); // 기본 3등분 크기 계산 int batchSize = 30000; // Batch 크기 설정 (고정값)
// Batch 크기가 50000을 초과하면 50000으로 제한 System.out.println("총 데이터 개수 :: " + totalSize);
batchSize = Math.min(batchSize, 50000); System.out.println("설정된 Batch 크기 :: " + batchSize);
int instCnt = 0; int instCnt = 0;
int batchCount = 0;
int j = 0; // 배치별 실행 시간 기록
for (int i = 0; i < totalSize; i += batchSize) { List<Double> batchExecutionTimes = new ArrayList<>();
// Batch 리스트 생성
List<MjonMsgSendVO> batchList = mjonMsgSendVOList.subList(
i, Math.min(i + batchSize, totalSize)
);
System.out.println("i : "+ i);
// DAO 호출
int insertedCount = mjonMsgDataDAO.insertMsgDataInfo_advc(batchList);
instCnt += insertedCount;
j++;
}
for (int i = 0; i < totalSize; i += batchSize) {
// Batch 시작 시간 측정
long batchStartTime = System.currentTimeMillis();
// Batch 리스트 생성
List<MjonMsgSendVO> batchList = mjonMsgSendVOList.subList(
i, Math.min(i + batchSize, totalSize)
);
System.out.println("Batch 시작 인덱스: " + i);
// DAO 호출
int insertedCount = mjonMsgDataDAO.insertMsgDataInfo_advc(batchList);
instCnt += insertedCount;
// Batch 종료 시간 측정 실행 시간 계산
long batchEndTime = System.currentTimeMillis();
double batchExecutionTimeInSeconds = (batchEndTime - batchStartTime) / 1000.0;
// 실행 시간 기록
batchExecutionTimes.add(batchExecutionTimeInSeconds);
batchCount++;
}
// 종료 시간 측정 // 종료 시간 측정
long endTime = System.currentTimeMillis(); long totalEndTime = System.currentTimeMillis();
// 실행 시간 계산 (밀리초 -> 초로 변환)
double executionTimeInSeconds = (endTime - startTime) / 1000.0; // 실행 시간 계산 (밀리초 -> 초로 변환)
double totalExecutionTimeInSeconds = (totalEndTime - totalStartTime) / 1000.0;
// 실행 시간 출력 // 실행 시간 출력
System.out.println("j :: " + j); System.out.println("총 배치 실행 횟수 :: " + batchCount);
System.out.println("batchSize :: " + batchSize); System.out.println("batchSize :: " + batchSize);
System.out.println("Execution time :: " + executionTimeInSeconds + "" + "// insert Cnt :: "+instCnt); System.out.println("총 실행 시간 :: " + totalExecutionTimeInSeconds + "");
System.out.println("총 삽입 건수 :: " + instCnt);
// 배치별 실행 시간 출력
for (int k = 0; k < batchExecutionTimes.size(); k++) {
System.out.println("배치 " + (k + 1) + " 실행 시간 :: " + batchExecutionTimes.get(k) + "");
}
// 강제로 IllegalArgumentException 발생시키기 // 강제로 IllegalArgumentException 발생시키기