1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "pch.h"
#include <iostream>
#include <vector>
#include <cmath>
#include <Windows.h>
 
int main() {
    const char* str1 = "aaaaaaaaaa_aaaaaaaaaa";
    const char* str2 = "bbbbbbbbbb_bbbbbbbbbb";
    int result = 0;
    DWORD start = 0end = 0;
 
    start = GetTickCount64();
    for (unsigned long long i = 0; i < 100'000'000'000; ++i) {
        result = std::strcmp(str1, str2);
    }
    end = GetTickCount64();
    std::printf("std::strcmp(): %ld\n", end - start);
    start = GetTickCount64();
    for (unsigned long long i = 0; i < 100'000'000'000++i) {
        result = str1 == str2;
    }
    end = GetTickCount64();
    std::printf("operator==: %ld\n"end - start);
}
cs

strcmp랑 ==랑 뭐가 더 빠른지 궁금해서 이렇게 했는데, 뭔가 성능 체크할때 이것 말고도 고려해야하는 부분 있음?
아니면 그냥 이렇게만 체크하고 어느 하드웨어 환경에서 테스트한거다~ 이런식으로 글만 남겨두면 됨?