This commit is contained in:
subsub 2024-12-02 10:00:16 +09:00
commit 782b2abc0a

View File

@ -4166,8 +4166,6 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
// 시작 시간 측정
long startTime = System.currentTimeMillis();
System.out.println("==================== insert 시작 ====================");
@ -4178,32 +4176,61 @@ public class MjonMsgDataServiceImpl extends EgovAbstractServiceImpl implements M
// int instCnt = mjonMsgDataDAO.insertMsgDataInfo_advc(mjonMsgSendVOList);
// int instCnt = mjonMsgDataDAO.insertMsgDataInfo_jdbc_advc(mjonMsgSendVOList);
//
// 시작 시간 측정
long totalStartTime = System.currentTimeMillis();
int totalSize = mjonMsgSendVOList.size(); // 데이터 개수
int batchSize = 50000; // Batch 크기 설정 (고정값)
System.out.println("총 데이터 개수 :: " + totalSize);
System.out.println("설정된 Batch 크기 :: " + batchSize);
int instCnt = 0;
int batchSize = (int) Math.ceil((double) mjonMsgSendVOList.size() / 3); // Batch 크기 계산
// Batch 처리
for (int i = 0; i < mjonMsgSendVOList.size(); i += batchSize) {
System.out.println(" i :: "+ i);
// Batch 크기만큼 리스트를 잘라냄
int batchCount = 0;
// 배치별 실행 시간 기록
List<Double> batchExecutionTimes = new ArrayList<>();
for (int i = 0; i < totalSize; i += batchSize) {
// Batch 시작 시간 측정
long batchStartTime = System.currentTimeMillis();
// Batch 리스트 생성
List<MjonMsgSendVO> batchList = mjonMsgSendVOList.subList(
i, Math.min(i + batchSize, mjonMsgSendVOList.size())
i, Math.min(i + batchSize, totalSize)
);
// DAO 메서드 호출
System.out.println("Batch 시작 인덱스: " + i);
// DAO 호출
int insertedCount = mjonMsgDataDAO.insertMsgDataInfo_advc(batchList);
instCnt += insertedCount; // 삽입된 건수 누적
instCnt += insertedCount;
// Batch 종료 시간 측정 실행 시간 계산
long batchEndTime = System.currentTimeMillis();
double batchExecutionTimeInSeconds = (batchEndTime - batchStartTime) / 1000.0;
// 실행 시간 기록
batchExecutionTimes.add(batchExecutionTimeInSeconds);
batchCount++;
}
// 종료 시간 측정
long endTime = System.currentTimeMillis();
// 실행 시간 계산 (밀리초 -> 초로 변환)
double executionTimeInSeconds = (endTime - startTime) / 1000.0;
long totalEndTime = System.currentTimeMillis();
// 실행 시간 계산 (밀리초 -> 초로 변환)
double totalExecutionTimeInSeconds = (totalEndTime - totalStartTime) / 1000.0;
// 실행 시간 출력
System.out.println("총 배치 실행 횟수 :: " + batchCount);
System.out.println("batchSize :: " + batchSize);
System.out.println("Execution time :: " + executionTimeInSeconds + "" + "// insert Cnt :: "+instCnt);
// mjonMsgSendVOList.stream().forEach(t-> System.out.print(t.toString()+"\n") );
// mjonMsgSendVOList.stream().forEach(t-> System.out.print(t.toString()+"\n") );
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 발생시키기