| 1 |
#include "NyxCore.h" |
| 2 |
#include <iostream> |
| 3 |
#include <windows.h> |
| 4 |
#include <memory> |
| 5 |
using namespace std; |
| 6 |
using namespace Nyx; |
| 7 |
|
| 8 |
void PrintInfo(Timer* timer) |
| 9 |
{ |
| 10 |
cout << "isPause = " << timer->isPaused << "\n"; |
| 11 |
cout << "offsetTime = " << timer->offsetTime << "\n"; |
| 12 |
cout << "pauseTime = " << timer->pauseTime << "\n"; |
| 13 |
cout << "timeCaps.dwMin = " << timer->timeCaps.wPeriodMin << "\n"; |
| 14 |
cout << "timeCaps.dwMax = " << timer->timeCaps.wPeriodMax << "\n" << endl;; |
| 15 |
} |
| 16 |
void PrintInfo(std::shared_ptr<Timer> timer) |
| 17 |
{ |
| 18 |
cout << "isPause = " << timer->isPaused << "\n"; |
| 19 |
cout << "offsetTime = " << timer->offsetTime << "\n"; |
| 20 |
cout << "pauseTime = " << timer->pauseTime << "\n"; |
| 21 |
cout << "timeCaps.dwMin = " << timer->timeCaps.wPeriodMin << "\n"; |
| 22 |
cout << "timeCaps.dwMax = " << timer->timeCaps.wPeriodMax << "\n" << endl;; |
| 23 |
} |
| 24 |
|
| 25 |
void PrintInfo(std::shared_ptr<FixedTimer> timer) |
| 26 |
{ |
| 27 |
PrintInfo(timer->timer); |
| 28 |
cout << "flushTime = " << timer->flushTime << "\n"<<endl; |
| 29 |
} |
| 30 |
|
| 31 |
void PrintInfo(std::shared_ptr<FPSTimer> timer) |
| 32 |
{ |
| 33 |
PrintInfo(timer->timer); |
| 34 |
cout <<"nowFPS = " << timer->nowFPS << endl; |
| 35 |
cout <<"beforeTime = " << timer->beforeTime << endl; |
| 36 |
cout <<"fps = " << timer->fps << endl; |
| 37 |
cout <<"fpsWait = " << timer->fpsWait << endl; |
| 38 |
cout <<"fpsWaitTT = " << timer->fpsWaitTT << endl; |
| 39 |
cout <<"frames = " << timer->frames << endl; |
| 40 |
cout <<"FPS30 = " << FPSTimer::FPS30 << endl; |
| 41 |
cout <<"FPS60 = " << FPSTimer::FPS60 << endl; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
//timer::Timer(); |
| 46 |
void Test1() |
| 47 |
{ |
| 48 |
std::shared_ptr<Timer> timer = std::make_shared<Timer>(); |
| 49 |
PrintInfo(timer); |
| 50 |
} |
| 51 |
|
| 52 |
//timer->Get(); |
| 53 |
void Test2() |
| 54 |
{ |
| 55 |
cout <<"timer->Get();"<<endl; |
| 56 |
|
| 57 |
std::shared_ptr<Timer> timer = std::make_shared<Timer>(); |
| 58 |
|
| 59 |
cout << "timeGetTime() = " << ::timeGetTime() <<"\n"; |
| 60 |
cout << "timer->Get() = " << timer->Get() <<"\n"; |
| 61 |
|
| 62 |
PrintInfo(timer); |
| 63 |
} |
| 64 |
|
| 65 |
//timer->Set(); |
| 66 |
void Test3() |
| 67 |
{ |
| 68 |
cout <<"timer->Set();"<<endl; |
| 69 |
|
| 70 |
std::shared_ptr<Timer> timer = std::make_shared<Timer>(); |
| 71 |
|
| 72 |
const unsigned long _now1 = ::timeGetTime(); |
| 73 |
cout << "timeGetTime() = " << _now1 <<"\n"; |
| 74 |
|
| 75 |
timer->Set(_now1); |
| 76 |
PrintInfo(timer); |
| 77 |
} |
| 78 |
//timer->Reset(); |
| 79 |
void Test4() |
| 80 |
{ |
| 81 |
cout << "timer->Reset()" << endl; |
| 82 |
|
| 83 |
std::shared_ptr<Timer> timer = std::make_shared<Timer>(); |
| 84 |
const unsigned long _now = ::timeGetTime(); |
| 85 |
|
| 86 |
cout << "timeGetTime() = " << _now <<"\n"; |
| 87 |
|
| 88 |
timer->Reset(); |
| 89 |
PrintInfo(timer); |
| 90 |
} |
| 91 |
|
| 92 |
//timer->Resatrt(); |
| 93 |
void Test5() |
| 94 |
{ |
| 95 |
cout << "timer->Restart()" << endl; |
| 96 |
std::shared_ptr<Timer> timer = std::make_shared<Timer>(); |
| 97 |
|
| 98 |
const unsigned long _now = ::timeGetTime(); |
| 99 |
|
| 100 |
cout << "timeGetTime() = " << _now <<"\n"; |
| 101 |
timer->Restart(); |
| 102 |
|
| 103 |
PrintInfo(timer); |
| 104 |
} |
| 105 |
|
| 106 |
//timer->Pause(); |
| 107 |
void Test6() |
| 108 |
{ |
| 109 |
cout << "timer->Pause()" << endl; |
| 110 |
|
| 111 |
std::shared_ptr<Timer> timer = std::make_shared<Timer>(); |
| 112 |
|
| 113 |
timer->Pause(true); |
| 114 |
cout << "timer::ispause = " << timer->IsPause() << endl; |
| 115 |
|
| 116 |
PrintInfo(timer); |
| 117 |
|
| 118 |
} |
| 119 |
|
| 120 |
//timer->Set()-> timer->Get(); |
| 121 |
void Test7() |
| 122 |
{ |
| 123 |
cout << "timer->Set() -> timer->Get()" << endl; |
| 124 |
std::shared_ptr<Timer> timer = std::make_shared<Timer>(); |
| 125 |
|
| 126 |
unsigned long _n = ::timeGetTime(); |
| 127 |
timer->Set(_n); |
| 128 |
cout << "timer->Get() "<<timer->Get(); |
| 129 |
|
| 130 |
PrintInfo(timer); |
| 131 |
|
| 132 |
} |
| 133 |
|
| 134 |
void Test8() |
| 135 |
{ |
| 136 |
cout << "timer->Pause()" << endl; |
| 137 |
|
| 138 |
std::shared_ptr<Timer> timer = std::make_shared<Timer>(); |
| 139 |
|
| 140 |
timer->Pause(true); |
| 141 |
cout << "timer::ispause = " << timer->IsPause() << endl; |
| 142 |
|
| 143 |
PrintInfo(timer); |
| 144 |
|
| 145 |
} |
| 146 |
|
| 147 |
//timer::FixedTimer(); |
| 148 |
void Test11() |
| 149 |
{ |
| 150 |
std::shared_ptr<FixedTimer> timer = std::make_shared<FixedTimer>(); |
| 151 |
PrintInfo(timer); |
| 152 |
} |
| 153 |
|
| 154 |
//timer->Get(); |
| 155 |
void Test12() |
| 156 |
{ |
| 157 |
cout <<"timer->Get();"<<endl; |
| 158 |
|
| 159 |
std::shared_ptr<FixedTimer> timer = std::make_shared<FixedTimer>(); |
| 160 |
|
| 161 |
cout << "timeGetTime() = " << ::timeGetTime() <<"\n"; |
| 162 |
cout << "timer->Get1() = " << timer->Get() <<"\n"; |
| 163 |
cout << "timer->Get2() = " << timer->Get() <<"\n"; |
| 164 |
|
| 165 |
PrintInfo(timer); |
| 166 |
} |
| 167 |
|
| 168 |
//timer->Set(); |
| 169 |
void Test13() |
| 170 |
{ |
| 171 |
cout <<"timer->Set();"<<endl; |
| 172 |
|
| 173 |
std::shared_ptr<FixedTimer> timer = std::make_shared<FixedTimer>(); |
| 174 |
|
| 175 |
const unsigned long _now1 = ::timeGetTime(); |
| 176 |
cout << "timeGetTime() = " << _now1 <<"\n"; |
| 177 |
|
| 178 |
timer->Set(_now1); |
| 179 |
PrintInfo(timer); |
| 180 |
} |
| 181 |
//timer->Reset(); |
| 182 |
void Test14() |
| 183 |
{ |
| 184 |
cout << "timer->Reset()" << endl; |
| 185 |
|
| 186 |
std::shared_ptr<FixedTimer> timer = std::make_shared<FixedTimer>(); |
| 187 |
const unsigned long _now = ::timeGetTime(); |
| 188 |
|
| 189 |
cout << "timeGetTime() = " << _now <<"\n"; |
| 190 |
|
| 191 |
timer->Reset(); |
| 192 |
PrintInfo(timer); |
| 193 |
} |
| 194 |
|
| 195 |
//timer->Resatrt(); |
| 196 |
void Test15() |
| 197 |
{ |
| 198 |
cout << "timer->Restart()" << endl; |
| 199 |
std::shared_ptr<FixedTimer> timer = std::make_shared<FixedTimer>(); |
| 200 |
|
| 201 |
const unsigned long _now = ::timeGetTime(); |
| 202 |
|
| 203 |
cout << "timeGetTime() = " << _now <<"\n"; |
| 204 |
timer->Restart(); |
| 205 |
|
| 206 |
PrintInfo(timer); |
| 207 |
} |
| 208 |
|
| 209 |
//timer->Pause(); |
| 210 |
void Test16() |
| 211 |
{ |
| 212 |
cout << "timer->Pause()" << endl; |
| 213 |
|
| 214 |
std::shared_ptr<FixedTimer> timer = std::make_shared<FixedTimer>(); |
| 215 |
|
| 216 |
timer->Pause(true); |
| 217 |
cout << "timer::ispause = " << timer->IsPause() << endl; |
| 218 |
|
| 219 |
PrintInfo(timer); |
| 220 |
|
| 221 |
} |
| 222 |
|
| 223 |
//timer->Set()-> timer->Get(); |
| 224 |
void Test17() |
| 225 |
{ |
| 226 |
cout << "timer->Set() -> timer->Get()" << endl; |
| 227 |
std::shared_ptr<FixedTimer> timer = std::make_shared<FixedTimer>(); |
| 228 |
|
| 229 |
unsigned long _n = ::timeGetTime(); |
| 230 |
timer->Set(_n); |
| 231 |
cout << "timer->Get() "<<timer->Get(); |
| 232 |
|
| 233 |
PrintInfo(timer); |
| 234 |
|
| 235 |
} |
| 236 |
|
| 237 |
void Test18() |
| 238 |
{ |
| 239 |
cout << "timer->Pause()" << endl; |
| 240 |
|
| 241 |
std::shared_ptr<FixedTimer> timer = std::make_shared<FixedTimer>(); |
| 242 |
|
| 243 |
timer->Pause(true); |
| 244 |
cout << "timer::ispause = " << timer->IsPause() << endl; |
| 245 |
|
| 246 |
PrintInfo(timer); |
| 247 |
|
| 248 |
} |
| 249 |
|
| 250 |
//timer::FPSTimer(); |
| 251 |
void Test21() |
| 252 |
{ |
| 253 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 254 |
PrintInfo(timer); |
| 255 |
} |
| 256 |
|
| 257 |
//timer->Get(); |
| 258 |
void Test22() |
| 259 |
{ |
| 260 |
cout <<"timer->Get();"<<endl; |
| 261 |
|
| 262 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 263 |
|
| 264 |
cout << "timeGetTime() = " << ::timeGetTime() <<"\n"; |
| 265 |
cout << "timer->Get1() = " << timer->Get() <<"\n"; |
| 266 |
cout << "timer->Get2() = " << timer->Get() <<"\n"; |
| 267 |
|
| 268 |
PrintInfo(timer); |
| 269 |
} |
| 270 |
|
| 271 |
//timer->Set(); |
| 272 |
void Test23() |
| 273 |
{ |
| 274 |
cout <<"timer->Set();"<<endl; |
| 275 |
|
| 276 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 277 |
|
| 278 |
const unsigned long _now1 = ::timeGetTime(); |
| 279 |
cout << "timeGetTime() = " << _now1 <<"\n"; |
| 280 |
|
| 281 |
timer->Set(_now1); |
| 282 |
PrintInfo(timer); |
| 283 |
} |
| 284 |
//timer->Reset(); |
| 285 |
void Test24() |
| 286 |
{ |
| 287 |
cout << "timer->Reset()" << endl; |
| 288 |
|
| 289 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 290 |
const unsigned long _now = ::timeGetTime(); |
| 291 |
|
| 292 |
cout << "timeGetTime() = " << _now <<"\n"; |
| 293 |
|
| 294 |
timer->Reset(); |
| 295 |
PrintInfo(timer); |
| 296 |
} |
| 297 |
|
| 298 |
//timer->Resatrt(); |
| 299 |
void Test25() |
| 300 |
{ |
| 301 |
cout << "timer->Restart()" << endl; |
| 302 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 303 |
|
| 304 |
const unsigned long _now = ::timeGetTime(); |
| 305 |
|
| 306 |
cout << "timeGetTime() = " << _now <<"\n"; |
| 307 |
timer->Restart(); |
| 308 |
|
| 309 |
PrintInfo(timer); |
| 310 |
} |
| 311 |
|
| 312 |
//timer->Pause(); |
| 313 |
void Test26() |
| 314 |
{ |
| 315 |
cout << "timer->Pause()" << endl; |
| 316 |
|
| 317 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 318 |
|
| 319 |
timer->Pause(true); |
| 320 |
cout << "timer::ispause = " << timer->IsPause() << endl; |
| 321 |
|
| 322 |
PrintInfo(timer); |
| 323 |
|
| 324 |
} |
| 325 |
|
| 326 |
//timer->Set()-> timer->Get(); |
| 327 |
void Test27() |
| 328 |
{ |
| 329 |
cout << "timer->Set() -> timer->Get()" << endl; |
| 330 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 331 |
|
| 332 |
unsigned long _n = ::timeGetTime(); |
| 333 |
timer->Set(_n); |
| 334 |
cout << "timer->Get() "<<timer->Get(); |
| 335 |
|
| 336 |
PrintInfo(timer); |
| 337 |
|
| 338 |
} |
| 339 |
|
| 340 |
void Test28() |
| 341 |
{ |
| 342 |
cout << "timer->GetFPS()" << endl; |
| 343 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 344 |
|
| 345 |
cout << "timer::GetFPS = " << timer->GetFPS() << endl; |
| 346 |
|
| 347 |
PrintInfo(timer); |
| 348 |
|
| 349 |
} |
| 350 |
|
| 351 |
void Test29() |
| 352 |
{ |
| 353 |
cout << "timer->GetNowFPS()" << endl; |
| 354 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 355 |
|
| 356 |
cout << "timer::GetNowFPS = " << timer->GetNowFPS() << endl; |
| 357 |
|
| 358 |
PrintInfo(timer); |
| 359 |
|
| 360 |
} |
| 361 |
|
| 362 |
|
| 363 |
void Test30() |
| 364 |
{ |
| 365 |
cout << "timer->GetNowFPS()" << endl; |
| 366 |
std::shared_ptr<FPSTimer> timer = std::make_shared<FPSTimer>(); |
| 367 |
|
| 368 |
int i=0; |
| 369 |
while (++i<100) { |
| 370 |
timer->WaitFrame(); |
| 371 |
cout <<"nowFPS" << timer->nowFPS << endl; |
| 372 |
} |
| 373 |
} |
| 374 |
|
| 375 |
void Test31() |
| 376 |
{ |
| 377 |
std::shared_ptr<PerformanceTimer> timer = std::make_shared<PerformanceTimer>(); |
| 378 |
bool res = timer->Initialize(); |
| 379 |
cout << "res" << res <<endl; |
| 380 |
} |
| 381 |
|
| 382 |
void Test32() |
| 383 |
{ |
| 384 |
std::shared_ptr<PerformanceTimer> timer = std::make_shared<PerformanceTimer>(); |
| 385 |
bool res = timer->Initialize(); |
| 386 |
cout << "res" << res <<endl; |
| 387 |
|
| 388 |
|
| 389 |
Tick tick = timer->GetTick(); |
| 390 |
cout << tick.QuadPart << endl; |
| 391 |
} |
| 392 |
void Test33() |
| 393 |
{ |
| 394 |
std::shared_ptr<PerformanceTimer> timer = std::make_shared<PerformanceTimer>(); |
| 395 |
bool res = timer->Initialize(); |
| 396 |
cout << "res" << res <<endl; |
| 397 |
|
| 398 |
|
| 399 |
Tick tick = timer->GetTick(); |
| 400 |
double r =timer->GetInterval(tick); |
| 401 |
cout << r << endl; |
| 402 |
} |
| 403 |
void Test34() |
| 404 |
{ |
| 405 |
std::shared_ptr<PerformanceTimer> timer = std::make_shared<PerformanceTimer>(); |
| 406 |
bool res = timer->Initialize(); |
| 407 |
cout << "res" << res <<endl; |
| 408 |
|
| 409 |
|
| 410 |
Tick tick1 = timer->GetTick(); |
| 411 |
Tick tick2 = timer->GetTick(); |
| 412 |
double r =timer->GetInterval(tick1, tick2); |
| 413 |
cout << r << endl; |
| 414 |
} |
| 415 |
|
| 416 |
int main(int argc,char*argv[]) |
| 417 |
{ |
| 418 |
Test1(); |
| 419 |
Test2(); |
| 420 |
Test3(); |
| 421 |
Test4(); |
| 422 |
Test5(); |
| 423 |
Test6(); |
| 424 |
Test7(); |
| 425 |
Test8(); |
| 426 |
Test11(); |
| 427 |
Test12(); |
| 428 |
Test13(); |
| 429 |
Test14(); |
| 430 |
Test15(); |
| 431 |
Test16(); |
| 432 |
Test17(); |
| 433 |
Test18(); |
| 434 |
Test21(); |
| 435 |
Test22(); |
| 436 |
Test23(); |
| 437 |
Test24(); |
| 438 |
Test25(); |
| 439 |
Test26(); |
| 440 |
Test27(); |
| 441 |
Test28(); |
| 442 |
Test29(); |
| 443 |
Test30(); |
| 444 |
Test31(); |
| 445 |
Test32(); |
| 446 |
Test33(); |
| 447 |
Test34(); |
| 448 |
getchar(); |
| 449 |
} |