This is a test to calculate average delays in epos2
#include <stdio.h>
#include <unistd.h>
#include <iostream>
#include <sstream>
#include "ctime.h"
#include "log.h"
CLog john("test_like_h3d");
cout << "Epos2 Like H3D:" << endl;
double avg=0,total_avg=0,max_avg=0,min_avg=0;
int total_seconds=20;
try{
CTime tbase,telapsed,t0,t1,tavg;
int32_t pos=0;
stringstream text;
int k=0;
telapsed.setFormat(ctf_ms);
do{
t0.set();
t1.set();
tavg = t1-t0;
avg = tavg.getTimeInSeconds();
telapsed = (t1+t0)/2 - tbase;
cout << ">>> " << telapsed.getTimeInSeconds() << " " << pos << endl;
if(total_avg==0)
total_avg = avg;
else
total_avg = (total_avg + avg)/2;
max_avg = max(max_avg,avg);
min_avg = min(min_avg,avg);
telapsed.set();
telapsed = telapsed - tbase;
if( telapsed.getTimeInSeconds() > 5*k )
{
cout << telapsed << endl;
k++;
}
}while( telapsed.getTimeInSeconds() < total_seconds);
cout << "End" << endl;
}catch(CException &e){
cout << e.what() << endl;
}
cout <<
" t avg: " << total_avg <<
" t min: " << min_avg <<
" t max: " << max_avg << endl;
return 1;
}