Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions k6/11-vacancy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function subscribe() {

const res = http.post(
`${BASE_URL}/api/v1/vacancy`,
JSON.stringify({ remainId: REMAIN_ID }),
JSON.stringify({ remainId: parseInt(REMAIN_ID, 10) }),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

⚠️ 중복 타입 변환 및 성능 개선 필요

REMAIN_ID는 이미 파일 상단(159번 라인)에서 Number(__ENV.REMAIN_ID || 0)를 통해 숫자 타입으로 변환되어 정의되어 있습니다.

또한, subscribe() 함수는 부하 테스트 실행 시 반복적으로 호출되는 핵심 루프(Hot Path)입니다. 매 요청마다 parseInt를 호출하는 것은 불필요한 오버헤드를 발생시킵니다.

만약 정수 파싱이 반드시 필요하다면, 매 요청마다 변환하는 대신 159번 라인의 초기화 시점에서 parseInt를 수행하고, 여기서는 이미 변환된 REMAIN_ID 상수를 그대로 사용하는 것이 성능과 가독성 측면에서 훨씬 효율적입니다.

Suggested change
JSON.stringify({ remainId: parseInt(REMAIN_ID, 10) }),
JSON.stringify({ remainId: REMAIN_ID }),

{
headers: {
'Content-Type': 'application/json',
Expand All @@ -230,11 +230,11 @@ function subscribe() {
async function smembers() {
if (!REDIS_KEY) throw new Error('REDIS_KEY env required');

// performance.now() 는 마이크로초 정밀도 (소수점 ms) 라 sub-ms 측정 가능.
// SMEMBERS 가 1ms 이하인 경우 Date.now() 로는 0 으로 측정되어 분포가 왜곡됨.
const start = performance.now();
// k6 v2 런타임에 performance 객체가 없어서 Date.now() 사용.
// 밀리초 정밀도라 sub-ms 호출은 0 으로 잡혀 분포가 약간 왜곡될 수 있다.
const start = Date.now();
const members = await redisClient.smembers(REDIS_KEY);
const duration = performance.now() - start;
const duration = Date.now() - start;

smembersDuration.add(duration);
smembersSize.add(members.length);
Expand Down
Loading