设为首页 加入收藏

TOP

数据结构内存管理c++实现(五)
2014-04-06 17:35:10 来源: 作者: 【 】 浏览:330
Tags:数据结构 内存 管理 实现

 

  void* p = malloc(sizeof(int));

  if(p)

  free(p);

  }

  end = (clock() - start) / (double)CLOCKS_PER_SEC;

  /*start = clock();

  for(int i = 0; i < times; ++i)

  {

  apr_memnode_t* p = apr_allocator_alloc(allocator, rrand(sizeof(int), 8192 * 2));

  if(p)

  apr_allocator_free(allocator, p);

  }

  end = (clock() - start) / (double)CLOCKS_PER_SEC;*/

  printf("malloc/free random size %d times, use %lf seconds\n", times, end[0]);

  printf("mempool allocate/deallocte random size %d times, use %lf seconds\n", times, end );

  printf("malloc/free fixed size %d times, use %lf seconds\n", times, end );

  //printf("apr alloc/free random size %d times, use %lf seconds\n", times, end );

  /* result at win32 release:

  malloc/free random size 1000000 times, use 7.251000 seconds

  mempool allocate/deallocte random size 1000000 times, use 0.031000 seconds

  malloc/free fixed size 1000000 times, use 0.360000 seconds

  apr alloc/free random size 1000000 times, use 0.031000 seconds

  */

  /* result at linux release

  malloc/free random size 1000000 times, use 0.070000 seconds

  mempool allocate/deallocte random size 1000000 times, use 0.030000 seconds

  malloc/free fixed size 1000000 times, use 0.040000 seconds

  apr alloc/free random size 1000000 times, use 0.040000 seconds

  */

  #ifdef _WIN32

  system("pause");

  #endif

  return 0;

  }

        

首页 上一页 2 3 4 5 下一页 尾页 5/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇用BOOST BIND库提高C++性能 下一篇C++写的socket网络爬虫

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C语言指针从入门到基 (2025-12-26 05:21:36)
·【C语言指针初阶】C (2025-12-26 05:21:33)
·C语言指针的定义和使 (2025-12-26 05:21:31)
·在 Redis 中如何查看 (2025-12-26 03:19:03)
·Redis在实际应用中, (2025-12-26 03:19:01)