代码拉取完成,页面将自动刷新
/* make_pgos.c
Simply runs through each of the most common code paths for PGO purposes
(C) 2010 Niall Douglas
*/
#define _CRT_SECURE_NO_WARNINGS 1 /* Don't care about MSVC warnings on POSIX functions */
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "nedmalloc.h"
#define RECORDS 100000
static void run(size_t maxsize, size_t records, size_t loops)
{
int n,m;
static void *mem[RECORDS];
for(m=0; m<loops; m++)
{
for(n=0; n<records-1; n++)
{
static int reallocflip;
int dorealloc=(reallocflip=!reallocflip);
size_t size=rand() & (maxsize-1);
if(!mem[n])
mem[n]=nedmalloc(size);
else if(n>0 && dorealloc)
mem[n-1]=nedrealloc(mem[n-1], size);
else if(n>1)
{
nedfree(mem[n-2]);
mem[n-2]=0;
}
}
}
for(n=0; n<records; n++)
{
if(mem[n])
{
nedfree(mem[n]);
mem[n]=0;
}
}
}
int main(void)
{
printf("nedmalloc PGO maker\n"
"-=-=-=-=-=-=-=-=-=-\n");
printf("Small allocations\n");
run(8192, RECORDS, 10);
printf("Medium allocations\n");
run(256*1024, RECORDS/100, 1000);
printf("Large allocations\n");
run(8*1024*1024, RECORDS/1000, 10000);
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。