tstheapswitch.cpp

来自「完成在tigersharc201平台上划分出多个heap的操作」· C++ 代码 · 共 58 行

CPP
58
字号
#include "stdlib.h"
#include "sysreg.h"
#include <stdio.h>
extern "C" { void _SDRAM_Init();}

volatile int cycles0, cycles1;
int main()
{
	
	float *test,*test2, *test3;
	int id;
	
	_SDRAM_Init();
	
	test = (float *)malloc(100*sizeof(float));
	
	heap_init(1);
	heap_switch(1);
	
	test2 = (float *)malloc(100*sizeof(float));
	
	heap_init(2);
	heap_switch(2);
	
	test3 = (float *)malloc(100*sizeof(float));
	
	int i = 0;
	
	cycles0 = __builtin_sysreg_read( __CCNT0 );         // read initial cycle count
	for (i = 0; i<1000; i++)
	{
		test[i] += test[i]*test[i];
	}
	cycles1 = __builtin_sysreg_read( __CCNT0 );         // read initial cycle count
	printf("ONE POINT INTERLEAVER cycles = %d\n", (cycles1 - cycles0)); 

	cycles0 = __builtin_sysreg_read( __CCNT0 );         // read initial cycle count
	for (i = 0; i<1000; i++)
	{
		test2[i] += test2[i]*test2[i];
	}
	cycles1 = __builtin_sysreg_read( __CCNT0 );         // read initial cycle count
	printf("ONE POINT INTERLEAVER cycles = %d\n", (cycles1 - cycles0)); 

	cycles0 = __builtin_sysreg_read( __CCNT0 );         // read initial cycle count
	for (i = 0; i<1000; i++)
	{
		test3[i] += test3[i]*test3[i];
	}
	cycles1 = __builtin_sysreg_read( __CCNT0 );         // read initial cycle count
	printf("ONE POINT INTERLEAVER cycles = %d\n", (cycles1 - cycles0)); 


	free(test);
	free(test2);
	free(test3);
}

⌨️ 快捷键说明

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