//
// HnxGC 
// 
#include "../comnhdr.h"

#include "hnxGC.h"

// #define TEST_CIRCULAR_REF

#if defined(TEST_CIRCULAR_REF)
class CNode {
public:
	HNXGC_ENABLE(CNode)
	gcptr<char>		m_pData;
	gcptr<CNode>	m_pSelf;
};
#endif

int main () {
	for (int j = 0; j < 100; j++) {
        int nGCCount = hnxgc.GetNumOfGC();
		BenchTicks_t bt = BenchTicksGetCurrent();

		for (int i = 0; i < 1000; i++) {
#if defined(TEST_CIRCULAR_REF)
			gcptr<CNode> p = gcnew CNode;
			
			p->m_pSelf = p; // circular reference to avoid RC taking place

			p->m_pData = gcnew char[500*1024];
#else
			gcnew char[500*1024];
#endif
		}

		bt = BenchTicksGetCurrent() - bt;
		printf("Completed in %s.\n", BenchTicksToString(bt, false));
	}
	return 0;
}

