소스 검색

进一步测试内存占用

master
tearshark 6 달 전
부모
커밋
f358e07891
3개의 변경된 파일8개의 추가작업 그리고 2개의 파일을 삭제
  1. 5
    1
      benchmark/benchmark_async_mem.cpp
  2. 1
    1
      include/librf/src/generator.h
  3. 2
    0
      tutorial/test_memory_leak.cpp

+ 5
- 1
benchmark/benchmark_async_mem.cpp 파일 보기

} }
} }
//clang : 平均 256 字节
//clang :
// x64: 平均 256 字节, operator new: size = 48, state size = 32
// x86: 平均 121 字节, operator new: size = 40, state size = 16
//msvc : 平均 304 字节(vs2022,17.7.4) //msvc : 平均 304 字节(vs2022,17.7.4)
// x64: 平均 304 字节, operator new: size = 144, state size = 32
// x86: 平均 153 字节, operator new: size = 72, state size = 16
#if LIBRF_TUTORIAL_STAND_ALONE #if LIBRF_TUTORIAL_STAND_ALONE
int main() int main()

+ 1
- 1
include/librf/src/generator.h 파일 보기

char* ptr = _Al.allocate(_Size + _State_size); char* ptr = _Al.allocate(_Size + _State_size);
char* _Rptr = ptr + _State_size; char* _Rptr = ptr + _State_size;
#if RESUMEF_DEBUG_COUNTER #if RESUMEF_DEBUG_COUNTER
std::cout << " generator_promise::new, alloc size=" << (_Size + _State_size) << std::endl;
std::cout << " generator_promise::new, alloc size=" << (_Size + _State_size) << ", state size=" << _State_size << std::endl;
std::cout << " generator_promise::new, alloc ptr=" << (void*)ptr << std::endl; std::cout << " generator_promise::new, alloc ptr=" << (void*)ptr << std::endl;
std::cout << " generator_promise::new, return ptr=" << (void*)_Rptr << std::endl; std::cout << " generator_promise::new, return ptr=" << (void*)_Rptr << std::endl;
#endif #endif

+ 2
- 0
tutorial/test_memory_leak.cpp 파일 보기

for (;;) for (;;)
{ {
bool val = co_await e.wait_for(1ms); bool val = co_await e.wait_for(1ms);
(void)val;
assert(val == false); assert(val == false);
co_await yield(); co_await yield();
} }
for (;;) for (;;)
{ {
bool val = co_await event_t::wait_all_for(1ms, e); bool val = co_await event_t::wait_all_for(1ms, e);
(void)val;
assert(val == false); assert(val == false);
co_await yield(); co_await yield();
} }

Loading…
취소
저장