zoukankan      html  css  js  c++  java
  • jemalloc 测试

    jemalloc安装

    wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
    tar xjf jemalloc-3.6.0.tar.bz2
    cd jemalloc-3.6.0
    ./configure
    make && make install
    echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
    ldconfig

    测试代码

    /*=============================================================================
    #     FileName: test.cpp
    #         Desc: G
    #       Author: Pugna
    #        Email: 860009944@qq.com
    #     HomePage: http://www.cnblogs.com/pugna/
    #      Version: 0.0.1
    #   LastChange: 2014-10-22 09:47:01
    #      History:
    =============================================================================*/
    #include <malloc.h>
    #include <stdio.h>
    #include <sys/time.h>
    
    static const int n=1000000;
    static const int msecond=1000000;
    
    int main(){
        void * p[n];
        struct timeval t_start,t_end;
        float timeuse;
        gettimeofday(&t_start,NULL);
        for(int i=0;i<n;i++){
            p[i]=malloc(10);
        }
        
        gettimeofday(&t_end,NULL);
        timeuse=msecond*(t_end.tv_sec-t_start.tv_sec)+t_end.tv_usec-t_start.tv_usec;
        timeuse/=msecond;
        printf("malloc use time:%f
    ",timeuse);
        gettimeofday(&t_start,NULL);
        for(int i=0;i<n;i++){
            p[i]=realloc(p[i],15);
        }
        gettimeofday(&t_end,NULL);
        timeuse=msecond*(t_end.tv_sec-t_start.tv_sec)+t_end.tv_usec-t_start.tv_usec;
        timeuse/=msecond;
        printf("realloc use time:%f
    ",timeuse);
        return 0;
    }

    没用jemalloc

    使用jemalloc

  • 相关阅读:
    android 入门-ID
    Win10 VS2015 社区版切换到VS2013社区版 进行维护之前的项目
    Win10 AppBar
    Win10 保存Element到相册
    LRUCache c#
    Winform解决界面重绘闪烁的问题
    使用Emit实现给实体赋值
    Winform 自定义窗体皮肤组件
    WPF 分享一种背景动画效果
    使用MEF与Castle实现AOP
  • 原文地址:https://www.cnblogs.com/pugna/p/4063342.html
Copyright © 2011-2022 走看看