이광한님이 만드신 메모리 풀 소스입니다.
Array를 지원하지 않아서 조금 수정한 버젼입니다.
10만껀에 100배 정도 차이가 나는군요
new/delete 13810
memory pool : 130
나중에 써 먹으려고 올려 놓습니다. 정도의 시간이 소요되는군요.
샘플 테스트
자료 출처 : 이광한님 홈페이지
Array를 지원하지 않아서 조금 수정한 버젼입니다.
10만껀에 100배 정도 차이가 나는군요
new/delete 13810
memory pool : 130
나중에 써 먹으려고 올려 놓습니다. 정도의 시간이 소요되는군요.
샘플 테스트
#include "stdafx.h"
//#include
class CObject
{
public:
CObject()
{
}
virtual ~CObject()
{
}
DECLARE_HEAP; // 필수
private:
char m_sText[1827];
};
DEFINE_HEAP(CObject, 200000); // 필수
int main()
{
//cout << "heap allocate" << endl;
long time = timeGetTime();
CObject* pObj[100000];
for(int i = 0; i < 100000; i++)
pObj[i] = new CObject;
//pObj[i] = new CObject[2];
for(i = 0; i < 100000; i++)
delete pObj[i];
//delete[] pObj[i];
long result = timeGetTime() - time;
//cout << "result: " << result << endl;
return 0;
}
//#include
class CObject
{
public:
CObject()
{
}
virtual ~CObject()
{
}
DECLARE_HEAP; // 필수
private:
char m_sText[1827];
};
DEFINE_HEAP(CObject, 200000); // 필수
int main()
{
//cout << "heap allocate" << endl;
long time = timeGetTime();
CObject* pObj[100000];
for(int i = 0; i < 100000; i++)
pObj[i] = new CObject;
//pObj[i] = new CObject[2];
for(i = 0; i < 100000; i++)
delete pObj[i];
//delete[] pObj[i];
long result = timeGetTime() - time;
//cout << "result: " << result << endl;
return 0;
}
헤더파일..
자료 출처 : 이광한님 홈페이지
'관심꺼리들 > General Programming' 카테고리의 다른 글
| ToLua++ 을 한번 적용해 볼까 하는데.. (0) | 2007/02/08 |
|---|---|
| SVN 설치완료! (0) | 2006/07/23 |
| Memory Pool (0) | 2006/06/09 |
| memory leak detect (5) | 2006/04/19 |
| 비트토렌트 ( BitTorrent ) (0) | 2006/03/12 |
| 아... 메모리 풀을 하나 만들어야 되는데.. (0) | 2005/12/27 |
mempool.zip

댓글을 달아 주세요