MCPcopy Create free account
hub / github.com/OpenArkStudio/ARK / SetDataTest

Method SetDataTest

samples/sample3/Sample3Module.cpp:397–462  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

395}
396
397void Sample3Module::SetDataTest(const AFGUID& guid, size_t count, const uint32_t index)
398{
399 auto pEntity = m_pKernelModule->GetEntity(guid);
400 if (nullptr == pEntity)
401 {
402 return;
403 }
404
405 std::cout << "----------[" << index << "] time [set int] test start----------" << std::endl;
406
407 // set data with int key
408 auto begin = std::chrono::system_clock::now().time_since_epoch();
409 for (size_t i = 0; i < count; i++)
410 {
411 pEntity->SetInt32(AFEntityMetaPlayer::gender_index(), 22);
412 }
413 auto end = std::chrono::system_clock::now().time_since_epoch();
414 auto time_int_key = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();
415
416 // set data with string key
417 begin = std::chrono::system_clock::now().time_since_epoch();
418 for (size_t i = 0; i < count; i++)
419 {
420 pEntity->SetInt32(AFEntityMetaPlayer::gender(), 22);
421 }
422 end = std::chrono::system_clock::now().time_since_epoch();
423 auto time_string_key = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();
424
425 std::cout << "[" << count << "] set with [int key] time = " << time_int_key << " ms"
426 << " with [string key] time = " << time_string_key << std::endl;
427
428 // set data with int key
429 begin = std::chrono::system_clock::now().time_since_epoch();
430 for (size_t i = 0; i < count; i++)
431 {
432 auto pObj = m_pKernelModule->GetEntity(guid);
433 if (nullptr == pObj)
434 {
435 return;
436 }
437
438 pObj->SetInt32(AFEntityMetaPlayer::gender_index(), 11);
439 }
440 end = std::chrono::system_clock::now().time_since_epoch();
441 time_int_key = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count();
442
443 // set data with string key
444 begin = std::chrono::system_clock::now().time_since_epoch();
445 for (size_t i = 0; i < count; i++)
446 {
447 auto pObj = m_pKernelModule->GetEntity(guid);
448 if (nullptr == pObj)
449 {
450 return;
451 }
452
453 pObj->SetInt32(AFEntityMetaPlayer::gender(), 11);
454 }

Callers

nothing calls this directly

Calls 4

nowClass · 0.85
GetEntityMethod · 0.80
countMethod · 0.80
SetInt32Method · 0.45

Tested by

no test coverage detected