2019-01-05 20:21:43 +08:00
|
|
|
|
// stdafx.h : include file for standard system include files,
|
|
|
|
|
|
// or project specific include files that are used frequently, but
|
|
|
|
|
|
// are changed infrequently
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#if !defined(AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_)
|
|
|
|
|
|
#define AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_
|
|
|
|
|
|
|
2019-01-17 20:41:51 +08:00
|
|
|
|
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>ZLIB
|
2025-01-15 18:49:15 +08:00
|
|
|
|
#define USING_ZLIB 0
|
2019-01-17 11:58:26 +08:00
|
|
|
|
|
2019-01-17 20:41:51 +08:00
|
|
|
|
#if !USING_ZLIB
|
|
|
|
|
|
// <20>Ƿ<EFBFBD>ʹ<EFBFBD><CAB9>LZ4
|
2025-01-15 18:49:15 +08:00
|
|
|
|
#define USING_LZ4 0
|
2025-02-07 18:59:15 +08:00
|
|
|
|
|
|
|
|
|
|
#if !USING_LZ4
|
|
|
|
|
|
#define USING_ZSTD 1
|
|
|
|
|
|
#define USING_CTX 1
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2019-01-17 20:41:51 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
#if _MSC_VER > 1000
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
#endif // _MSC_VER > 1000
|
|
|
|
|
|
|
2025-01-15 18:49:15 +08:00
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
#define Mprintf(format, ...) printf(format, ##__VA_ARGS__)
|
|
|
|
|
|
#else
|
|
|
|
|
|
#define Mprintf(format, ...)
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD>й©<D0B9><C2A9><EFBFBD>谲װVLD<4C><44><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
|
|
|
|
|
|
#include "vld.h"
|
|
|
|
|
|
|
|
|
|
|
|
// Insert your headers here
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
|
|
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: reference additional headers your program requires here
|
|
|
|
|
|
|
|
|
|
|
|
//{{AFX_INSERT_LOCATION}}
|
|
|
|
|
|
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !defined(AFX_STDAFX_H__46CA6496_AAD6_4658_B6E9_D7AEB26CDCD5__INCLUDED_)
|
|
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
#include <MMSystem.h>
|
|
|
|
|
|
#pragma comment(lib, "winmm.lib")
|
|
|
|
|
|
|
|
|
|
|
|
// <20>߾<EFBFBD><DFBE>ȵ<EFBFBD>˯<EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD>
|
|
|
|
|
|
#define Sleep_m(ms) { timeBeginPeriod(1); Sleep(ms); timeEndPeriod(1); }
|
|
|
|
|
|
|
|
|
|
|
|
// <20>Բ<EFBFBD><D4B2><EFBFBD>n<EFBFBD><6E><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD>µȴ<C2B5>T<EFBFBD><54>(n<>Dz<EFBFBD><C7B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1000)
|
|
|
|
|
|
#define WAIT_n(C, T, n) {assert(!(1000%(n)));int s=(1000*(T))/(n);do{Sleep(n);}while((C)&&(--s));}
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ʱ<EFBFBD>ȴ<EFBFBD>T<EFBFBD><54>(<28><><EFBFBD><EFBFBD>10ms)
|
|
|
|
|
|
#define WAIT(C, T) { timeBeginPeriod(1); WAIT_n(C, T, 10); timeEndPeriod(1); }
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><43><EFBFBD><EFBFBD>ʱ<EFBFBD>ȴ<EFBFBD>T<EFBFBD><54>(<28><><EFBFBD><EFBFBD>1ms)
|
|
|
|
|
|
#define WAIT_1(C, T) { timeBeginPeriod(1); WAIT_n(C, T, 1); timeEndPeriod(1); }
|
2019-01-10 19:35:03 +08:00
|
|
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ܼ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㺯<EFBFBD><E3BAAF><EFBFBD>ĺ<EFBFBD>ʱ
|
|
|
|
|
|
class auto_tick
|
|
|
|
|
|
{
|
|
|
|
|
|
private:
|
|
|
|
|
|
const char *func;
|
2019-09-07 10:47:50 +08:00
|
|
|
|
int span;
|
2019-01-10 19:35:03 +08:00
|
|
|
|
clock_t tick;
|
|
|
|
|
|
__inline clock_t now() const { return clock(); }
|
2019-09-07 10:47:50 +08:00
|
|
|
|
__inline int time() const { return now() - tick; }
|
2019-01-10 19:35:03 +08:00
|
|
|
|
|
|
|
|
|
|
public:
|
2019-09-07 10:47:50 +08:00
|
|
|
|
auto_tick(const char *func_name, int th = 5) : func(func_name), span(th), tick(now()) { }
|
|
|
|
|
|
~auto_tick() { stop(); }
|
|
|
|
|
|
|
|
|
|
|
|
__inline void stop() {
|
2025-01-15 18:49:15 +08:00
|
|
|
|
if (span != 0) { int s(this->time()); if (s > span)Mprintf("[%s]ִ<><D6B4>ʱ<EFBFBD><CAB1>: [%d]ms.\n", func, s); span = 0; }
|
2019-09-07 10:47:50 +08:00
|
|
|
|
}
|
2019-01-10 19:35:03 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
// <20><><EFBFBD>ܼ<EFBFBD><DCBC>㵱ǰ<E3B5B1><C7B0><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ӡ
|
2019-01-17 11:58:26 +08:00
|
|
|
|
#define AUTO_TICK(thresh) auto_tick TICK(__FUNCTION__, thresh)
|
2019-09-07 10:47:50 +08:00
|
|
|
|
#define STOP_TICK TICK.stop()
|
2019-01-10 19:35:03 +08:00
|
|
|
|
#else
|
|
|
|
|
|
#define AUTO_TICK(thresh)
|
2019-09-07 10:47:50 +08:00
|
|
|
|
#define STOP_TICK
|
2019-01-10 19:35:03 +08:00
|
|
|
|
#endif
|
2025-03-13 23:34:33 +08:00
|
|
|
|
|
|
|
|
|
|
#ifndef SAFE_DELETE
|
|
|
|
|
|
#define SAFE_DELETE(p) if(NULL !=(p)){ delete (p);(p) = NULL;}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SAFE_DELETE_ARRAY
|
|
|
|
|
|
#define SAFE_DELETE_ARRAY(p) if(NULL !=(p)){ delete[] (p);(p) = NULL;}
|
|
|
|
|
|
#endif
|