입력 대기 시간을 테스트 할 수있는 간단한 프로그램을 만들었습니다.입력 지연 검사기
나는이 의미는 컴퓨터가 화면에 보내는 것과 키보드의 관계에서 키를 누를 때까지의 지연을 의미합니다. 온라인 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
}
http://codereview.stackexchange.com이 이런 종류의 질문에 더 좋은 장소 일 수 있습니다. –
안녕하세요. 감사합니다. 거기에 게시 해 보겠습니다. 미안 해요, 이거 처음이에요. – Fdisk
이 질문은 코드 검토 및 테스트 이론에 관한 주제이므로 다루지 않습니다. http://codereview.stackexchange.com/questions/27994/simple-input-lag-test –