-
大小: 18.17MB文件类型: .rar金币: 1下载: 0 次发布日期: 2023-07-26
- 语言: 其他
- 标签: skynet_windo
资源简介
skynet_windows版本,2015编译版
代码片段和文件信息
// jemalloc C++ threaded test
// Author: Rustam Abdullaev
// Public Domain
#include
#include
#include
#include
#include
#include
#include
#include
using std::vector;
using std::thread;
using std::uniform_int_distribution;
using std::minstd_rand;
int test_threads() {
je_malloc_conf = “narenas:3“;
int narenas = 0;
size_t sz = sizeof(narenas);
je_mallctl(“opt.narenas“ (void *)&narenas &sz NULL 0);
if (narenas != 3) {
printf(“Error: unexpected number of arenas: %d\n“ narenas);
return 1;
}
static const int sizes[] = { 7 16 32 60 91 100 120 144 169 199 255 400 670 900 917 1025 3333 5190 13131 49192 99999 123123 255265 2333111 };
static const int numSizes = (int)(sizeof(sizes) / sizeof(sizes[0]));
vector workers;
static const int numThreads = narenas + 1 numAllocsMax = 25 numIter1 = 50 numIter2 = 50;
je_malloc_stats_print(NULL NULL NULL);
size_t allocated1;
size_t sz1 = sizeof(allocated1);
je_mallctl(“stats.active“ (void *)&allocated1 &sz1 NULL 0);
printf(“\nPress Enter to start threads...\n“);
getchar();
printf(“Starting %d threads x %d x %d iterations...\n“ numThreads numIter1 numIter2);
for (int i = 0; i < numThreads; i++) {
workers.emplace_back([tid=i]() {
uniform_int_distribution sizeDist(0 numSizes - 1);
minstd_rand rnd(tid * 17);
uint8_t* ptrs[numAllocsMax];
int ptrsz[numAllocsMax];
for (int i = 0; i < numIter1; ++i) {
thread t([&]() {
for (int i = 0; i < numIter2; ++i) {
const int numAllocs = numAllocsMax - sizeDist(rnd);
for (int j = 0; j < numAllocs; j += 64) {
const int x = sizeDist(rnd);
const int sz = sizes[x];
ptrsz[j] = sz;
ptrs[j] = (uint8_t*)je_malloc(sz);
if (!ptrs[j]) {
printf(“Unable to allocate %d bytes in thread %d iter %d alloc %d. %d\n“ sz tid i j x);
exit(1);
}
for (int k = 0; k < sz; k++)
ptrs[j][k] = tid + k;
}
for (int j = 0; j < numAllocs; j += 64) {
for (int k = 0 sz = ptrsz[j]; k < sz; k++)
if (ptrs[j][k] != (uint8_t)(tid + k)) {
printf(“Memory error in thread %d iter %d alloc %d @ %d : %02X!=%02X\n“ tid i j k ptrs[j][k] (uint8_t)(tid + k));
exit(1);
}
je_free(ptrs[j]);
}
}
});
t.join();
}
});
}
for (thread& t : workers) {
t.join();
}
je_malloc_stats_print(NULL NULL NULL);
size_t allocated2;
je_mallctl(“stats.active“ (void *)&allocated2 &sz1 NULL 0);
size_t leaked = allocated2 - allocated1;
printf(“\nDone. Leaked: %zd bytes\n“ leaked);
bool failed = leaked > 65536; // in case C++ runtime allocated something (
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 217 2018-09-07 16:33 skynet\.gitignore
文件 96 2018-02-26 09:35 skynet\.gitmodules
文件 985 2018-02-26 10:06 skynet\3rd\jemalloc\.appveyor.yml
文件 107 2018-02-26 10:06 skynet\3rd\jemalloc\.autom4te.cfg
文件 40 2018-02-26 10:06 skynet\3rd\jemalloc\.git
文件 19 2018-02-26 10:06 skynet\3rd\jemalloc\.gitattributes
文件 1900 2018-02-26 10:06 skynet\3rd\jemalloc\.gitignore
文件 8848 2018-02-26 10:06 skynet\3rd\jemalloc\.travis.yml
文件 266 2018-02-26 10:06 skynet\3rd\jemalloc\autogen.sh
文件 1820 2018-02-26 10:06 skynet\3rd\jemalloc\bin\jemalloc-config
文件 1598 2018-02-26 10:06 skynet\3rd\jemalloc\bin\jemalloc-config.in
文件 145 2018-02-26 10:06 skynet\3rd\jemalloc\bin\jemalloc.sh
文件 151 2018-02-26 10:06 skynet\3rd\jemalloc\bin\jemalloc.sh.in
文件 179108 2018-02-26 10:06 skynet\3rd\jemalloc\bin\jeprof
文件 179259 2018-02-26 10:06 skynet\3rd\jemalloc\bin\jeprof.in
文件 43940 2018-02-26 10:06 skynet\3rd\jemalloc\build-aux\config.guess
文件 36339 2018-02-26 10:06 skynet\3rd\jemalloc\build-aux\config.sub
文件 5585 2018-02-26 10:06 skynet\3rd\jemalloc\build-aux\install-sh
文件 61410 2018-02-26 10:06 skynet\3rd\jemalloc\ChangeLog
文件 158982 2018-02-26 10:06 skynet\3rd\jemalloc\config.log
文件 0 2018-02-26 10:06 skynet\3rd\jemalloc\config.stamp
文件 0 2018-02-26 10:06 skynet\3rd\jemalloc\config.stamp.in
文件 41840 2018-02-26 10:06 skynet\3rd\jemalloc\config.status
文件 356172 2018-02-26 10:06 skynet\3rd\jemalloc\configure
文件 69672 2018-02-26 10:06 skynet\3rd\jemalloc\configure.ac
文件 1703 2018-02-26 10:06 skynet\3rd\jemalloc\COPYING
文件 260 2018-02-26 10:06 skynet\3rd\jemalloc\doc\html.xsl
文件 249 2018-02-26 10:06 skynet\3rd\jemalloc\doc\html.xsl.in
文件 148978 2018-02-26 10:06 skynet\3rd\jemalloc\doc\jemalloc.xm
文件 148916 2018-02-26 10:06 skynet\3rd\jemalloc\doc\jemalloc.xm
............此处省略1059个文件信息
- 上一篇:max30102资料
- 下一篇:安卓五子棋源码 可实现人机对战
评论
共有 条评论