2013-07-01 1 views
2

입력 대기 시간을 테스트 할 수있는 간단한 프로그램을 만들었습니다.입력 지연 검사기

나는이 의미는 컴퓨터가 화면에 보내는 것과 키보드의 관계에서 키를 누를 때까지의 지연을 의미합니다. 온라인 1 인칭 슈팅 게임의 설정을 테스트하기위한 것입니다.

이 프로그램은 특정 리듬으로 콘솔 창을 흑백으로 깜박이고 사용자에게 스페이스 바를 누르거나 그 리듬에 대한 다른 키를 누르라고 요청합니다. getch를 사용하여 키를 눌렀을 때를 결정하고 OpenMP를 사용하여 깜박이는 콘솔과 병행하여 getch를 처리하는 기능을 실행합니다.

기본적으로 무료 입력 지연 테스트로 사용할 수 있습니까? 그렇지 않은 경우 어떻게해야합니까?

//Fdisk's input lag tester 
#include <omp.h> 
#include <stdio.h> 
#include <time.h> 
#include <unistd.h> 
#include <stdlib.h> 
#include <conio.h> 
using namespace std; 

//My global variables. My functions run in parallel so it's easier to use global variables here. 
    int i=0; 
    long int outp[11]; 
    long int inpu[11]; 

//This function takes the input 
int inputfunc() { 
while(i<11) { 
    getch(); //Takes the key input 
    inpu[i]=clock(); //Marks the time the key was pressed 
    if(inpu[i]-outp[i]>=0 && inpu[i]-outp[i]<5000) //Checks if result is valid 
    i++; //Moves the program along so it doesn't blink for eternity 
} 
return 0; 
} 

//This function causes the screen to change color 
int outputfunc() { 
while(i<11) { 
    system("color F0"); //Changes screen to white 
    outp[i]=clock(); //Marks the time when screen became white 
    usleep(400000); //Pause a bit here 
    system("color 0F"); //Make the screen black again 
    usleep(400000); //Pause again 
} 
return 0; 
} 
int main() { 
    printf("Fdisk's Input Lag Tester\n\nPress any key when the screen flashes WHITE.  Let it flash a few times before pressing anything, so you can get used to the  rhythm. Using the spacebar is recommended. Be as precise as possible with what you  see on screen. A multicore or multithreading processor is required.\n"); 
    system("pause"); //Sorry my coding is bad 
    system("cls"); //Again 
#pragma omp parallel sections //Parallel sections, these run in parallel on a dual core or dual threading machine 
{ 
    #pragma omp section 
    { 
     outputfunc(); //The output function, changes the screen's color 
    } 
    #pragma omp section 
    { 
     inputfunc(); //The input functions, waits for keypresses 
    } 
} 
long int x; 
for(i=0;i<11;i++) { 
x=x+(inpu[i]-outp[i]); //Difference between input and output=latency. This adds them up so we can take a mean value. 
} 
x=x/11; //This takes the mean value 
x=x*(1000/CLOCKS_PER_SEC); //I think clock is always set to milliseconds but in case it's not 
printf("Your input latency: %ims\n",x); //Gives the input latency to the user 
system("pause"); //Pauses the program so it doesn't exit in case not running it from a command line 
usleep(10000000); //Prevents someone from mindlessly pressing space to exit 
system("pause"); //Another redundancy to prevent accidental quitting 
} 
+2

http://codereview.stackexchange.com이 이런 종류의 질문에 더 좋은 장소 일 수 있습니다. –

+0

안녕하세요. 감사합니다. 거기에 게시 해 보겠습니다. 미안 해요, 이거 처음이에요. – Fdisk

+0

이 질문은 코드 검토 및 테스트 이론에 관한 주제이므로 다루지 않습니다. http://codereview.stackexchange.com/questions/27994/simple-input-lag-test –

답변

0

귀하의 테스트 절차가 측정하려고하는 지연의 대략적인 추정치를 제공하지 않을 것으로 생각됩니다. 리듬 감각, 손의 눈 조정, 커피 등을 가졌는지 등 사용자의 의견에 너무 많이 달려 있습니다. 또한 인간은 두 가지 사건을 구분하는 힘든 시간을 가지고 있음을 명심하십시오. ~ 30ms 떨어져 있기 때문에 결과의 정밀도에 영향을 미칩니다.

나는 다른 맥락에서 컴퓨터 지연의 유사한 평가를 수행해야했지만 사용 된 절차가 귀하의 경우에 적용될 수 있다고 생각합니다. 디지털 카메라 -> 이미지 수집 및 처리 하드웨어 -> Windows 응용 프로그램 -> 디스플레이와 같은 시스템의 종단 간 지연을 측정해야했습니다. 카메라로 나는 카메라 플래시를 촬영했다. 나는 두 번째 카메라 (고속)를 사용하여 플래시와 모니터 모두를 모니터에 찍었다. 제 2 카메라의 비디오를 통해 모니터에서 원본 플래시와 디스플레이 사이에 경과 된 프레임 수를 측정 할 수있었습니다.

경우에 따라 카메라와 필름을 촬영하여 키보드와 모니터를 모두 녹화 한 다음 비디오를 파일로 저장할 수 있습니다. 키보드를 치고 모니터에서 결과를 볼 수 있습니다. 모든 비디오 편집 소프트웨어를 사용하면 결과를 표시하는 데 필요한 프레임 수를 측정 할 수 있습니다. 물론 정밀도는 카메라의 프레임 속도에 따라 달라집니다. 예를 들어 표준 30fps 카메라가있는 경우 측정 된 지연은 33ms의 배수가됩니다. 더 높은 정밀도가 필요한 경우 더 높은 프레임 속도의 카메라를 항상 사용할 수 있습니다.