2

入力レイテンシをテストできる簡単なプログラムを作成しました。

これが意味するのは、コンピューターが画面に送信するものと、それに関連してキーを押すときとの間の遅延です。これは、オンラインの一人称シューティング ゲームのセットアップをテストするためのものです。

このプログラムは、特定のリズムでコンソール ウィンドウを白黒で点滅させ、ユーザーにそのリズムに合わせてスペースバーまたはその他のキーを押すように求めます。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
 }
4

1 に答える 1

0

あなたのテスト手順では、測定しようとしているラグの大まかな見積もりすら提供できないと思います。それはユーザーの入力、つまりリズム感があるかどうか、手と目の協調性があるかどうか、コーヒーを飲んでいるかどうかなどに大きく依存しています... また、人間は、より少ない 2 つのイベントを区別するのに苦労していることを覚えておいてください。結果の精度に影響を与えるため、最大 30 ミリ秒間隔よりも長くなります。

コンピューターのラグについて同様の評価を別の状況で実行する必要がありましたが、使用した手順をあなたのケースに適用できると思います。システムのエンドツーエンドの遅延を測定する必要がありました: デジタル カメラ -> 画像取得および処理ハードウェア -> Windows アプリケーション -> ディスプレイ。カメラでカメラのフラッシュを撮影しました。次に、2 台目のカメラ (高速) を使用して、フラッシュとそのモニター上の表示の両方を撮影しました。2 番目のカメラのビデオを調べて、元のフラッシュとモニター上での表示の間に経過したフレーム数を測定できました。

あなたの場合、任意のカメラとキーボードとモニターの両方を撮影し、ビデオをファイルに保存できます。キーボードを叩いて結果をモニターで見ることができます。任意のビデオ編集ソフトウェアを使用して、結果が表示されるまでにかかったフレーム数を測定できます。もちろん、精度はカメラのフレームレートに依存します。たとえば、標準の 30 fps カメラを使用している場合、測定されたラグは 33 ミリ秒の倍数になります。より高い精度が必要な場合は、常にフレーム レートの高いカメラを使用できます。

于 2013-08-12T18:06:04.833 に答える