?? cyccount.c
字號:
#define C1
#ifdef C1
//cycCount.c
// managament of time-stamp counter (Pentium)
// $Revision: 1.0 $
//***************************************************************************/
//*
//* Copyright (c) 1998-99 Intel Corporation.
//* All rights reserved.
//*
//*
//***************************************************************************/
#define CALL_CPUID _asm _emit 0x60 __asm _emit 0x0F __asm _emit 0xA2 _asm _emit 0x61
#define RTDSC __asm _emit 0x0F __asm _emit 0x31
long EventTime[32] = //accummulator for time spent during event
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
long EventStart[32] = //register start of current measurment for event
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // while measurment is active
long IterCount[16] = //iterartion counter for event
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void start_time_event(long, long);
void end_time_event(long);
void reset_time_event_info(long);
long get_time_event_info(long);
/*
struct num_functions {
char name[32];
long total;
long avg;
long cnt;
} numf[10] = {
"rgb_ycc_convert", 0, 0, 0,
"MRGB2YCbCr", 0, 0, 0,
"forward_DCT", 0, 0, 0,
"h2v1_downsample", 0, 0, 0,
"h2v2_downsample", 0, 0, 0,
"h2v2_merged_upsample", 0, 0, 0,
"h2v1_fancy_upsample", 0, 0, 0,
"h2v2_fancy_upsample", 0, 0, 0,
"jpeg_idct_4x4", 0, 0, 0,
"jpeg_idct_4x2", 0, 0, 0 };
*/
//*.**PROCEDURE ABSTRACT*****************************************************
//*.
//*. FUNCTION: VOID _start_time_event( iCounter:DWORD, bIterOnceMore: DWORD )
//*. ABSTRACT: registers start of timing event no. iCounter. if bIterOnceMore is
//*. set, the iteration counter for this event is increased
//*.
//*.*************************************************************************
void start_time_event(long iCounter, long bIterOnceMore)
{
long hi_time, lo_time;
__asm {
CALL_CPUID
; RDTSC ;//get time-stamp information in EDX:EAX
_emit 0x0F
_emit 0x31
MOV hi_time, edx
MOV lo_time, eax
}
EventStart[2*iCounter] = lo_time; //store lower 32-bit
EventStart[2*iCounter+1] = hi_time; //store upper 32-bit
if (bIterOnceMore)
IterCount[iCounter]++;
}
//*.**PROCEDURE ABSTRACT*****************************************************
//*.
//*. FUNCTION: VOID _end_time_event( iCounter:DWORD)
//*. ABSTRACT: registers end of timing event no. iCounter.
//*.
//*.
//*.*************************************************************************
void end_time_event(long iCounter)
{
long hi_time, lo_time, // EDX, EAX
lower32, upper32; // EBX, ECX
__asm {
CALL_CPUID
; RDTSC ;//get time-stamp information in EDX:EAX
_emit 0x0F
_emit 0x31
MOV lo_time, EAX ;//store lower 32-bit
MOV hi_time, EDX
}
lower32 = EventStart[2*iCounter];
upper32 = EventStart[2*iCounter+1];
lo_time -= lower32; // SUB
hi_time = (lo_time < 0) ? hi_time - upper32 + 1 : hi_time - upper32; // SBB
if (lo_time < 0)
lo_time *= -1;
lower32 = EventTime[2*iCounter];
upper32 = EventTime[2*iCounter+1];
lo_time += lower32;
hi_time += upper32;
EventTime[2*iCounter] = lo_time;
EventTime[2*iCounter+1] = hi_time;
}
//*.**PROCEDURE ABSTRACT*****************************************************
//*.
//*. FUNCTION: DWORD _get_time_event_info( iCounter:DWORD)
//*. ABSTRACT: query for timing event no. iCounter.
//*. RETURNS:
//*. Number of clock cycles spent in event no. iCounter, divided by
//*. the iteration counter for that event.
//*.
//*. NOTES:
//*. Only lower 32 bits of result are returned
//*.
//*.*************************************************************************
long get_time_event_info(long iCounter)
{
long hi_time, lo_time, // EDX, EAX
lower32; // EBX, ECX
// lower32, upper32; // EBX, ECX
lo_time = EventTime[2*iCounter];
hi_time = EventTime[2*iCounter+1];
lower32 = IterCount[iCounter];
if (lower32)
lo_time /= lower32;
return lo_time;
}
//*.**PROCEDURE ABSTRACT*****************************************************
//*.
//*. FUNCTION: VOID _reset_time_event_info( iCounter:DWORD)
//*. ABSTRACT: forget all information about timing event no. iCounter.
//*.
//*.
//*.*************************************************************************
void reset_time_event_info(long iCounter)
{
long lo_time = 0L; // EAX
EventStart[2*iCounter] = lo_time;
EventStart[2*iCounter+1] = lo_time;
EventTime[2*iCounter] = lo_time;
EventTime[2*iCounter+1] = lo_time;
IterCount[iCounter] = lo_time;
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -