
#include <windows.h>
#include <stdio.h>


typedef struct wmvdebug
{
	DWORD begin;
	DWORD end;
	DWORD t1, t2;
	DWORD count;
	DWORD total;
	DWORD average;
} wmvdebug;

 
wmvdebug* wmvdebugtab[2] = {NULL, NULL};


void wmvdebug_on (int ref)
{
//MMechostr(0,"dbg: wmvdebug_on\n");
	if (wmvdebugtab[ref] == NULL)
	{
		wmvdebugtab[ref] = (wmvdebug*) malloc (sizeof(wmvdebug));
		wmvdebugtab[ref]->begin = GetTickCount();
		wmvdebugtab[ref]->count = 0;
		wmvdebugtab[ref]->average = 0;
		wmvdebugtab[ref]->total = 0;
	}
	wmvdebugtab[ref]->t1 = GetTickCount();
}



void wmvdebug_off (int ref)
{
//MMechostr(0,"dbg: wmvdebug_off\n");
	wmvdebugtab[ref]->t2 = GetTickCount();
	wmvdebugtab[ref]->end = GetTickCount();
	wmvdebugtab[ref]->count++;

	wmvdebugtab[ref]->total += (wmvdebugtab[ref]->t2 - wmvdebugtab[ref]->t1);

	wmvdebugtab[ref]->average = wmvdebugtab[ref]->total / wmvdebugtab[ref]->count;
}


void wmvdebug_log (int ref)
{
	char tmp[256];
	char title[64];
//MMechostr(0,"dbg: wmvdebug_log\n");
	sprintf (&title[0], "log wmvdebug ref (%d)", ref);
	sprintf (&tmp[0], "count %d\ntotal %d\naverage %d", wmvdebugtab[ref]->count, wmvdebugtab[ref]->total, wmvdebugtab[ref]->average);
	MessageBox (NULL, tmp, title, 0);
}