⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readm.c

📁 代码优化,有效使用内存,透视优化技术,对比优化方法,如果你在追求代码效率的最大化,该资源你不能不读.
💻 C
字号:
/*----------------------------------------------------------------------------
 *
 *				EXAMPLE DEMONSTRATING INCONSTANCY
 *			of the memory block processing	time
 *          ======================================
 *
 * Build 0x001 16.08.2002
----------------------------------------------------------------------------*/
//#define __OVER_BRANCH__
// ^^^^ remove the comments from the previous line to activate "over-branching"
// and saturate the branch prediction block to clear the result from
// introduced distortions
#include <DoCPU.h>
#define	BLOCK_SIZE	_NORMAL

main()
{
	int		*p;
	int		x = 0;

	#define	a (int *)((char *)p + x)
	#define	b (int *)((char *)p + BLOCK_SIZE - x)

	p = (int *) malloc(BLOCK_SIZE);

    PRINT_TITLE; PRINT(("= = = Demonstrating inconstancy of the memory block processing time = = =\n"));

	A_BEGIN(0)
		for (x = 0; x < BLOCK_SIZE/2; x += sizeof(int))
		{
			#ifdef __OVER_BRANCH__
				if (x & 1)
			#endif
				*a = *a^*b; *b = *b^*a; *a = *a^*b;
		}
	A_END(0)

	// displaying the result of all measurements
	A_LIST_ITER(0)
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -