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

  • 相关阅读:
    【转载】Chrome 0day漏洞:不要用Chrome查看pdf文件
    内网渗透闲谈
    Sticky Fingure安装教程
    局域网下交换机配置
    Access 2010 应用基础 单元三:SQL查询
    ESP8266 wifi干扰、钓鱼实现
    这是谁的锅
    svn/git的diff、patch
    sublime开发php必备工具集合(mac)
    gcc学习笔记
  • 原文地址:https://www.cnblogs.com/pugna/p/4063342.html
Copyright © 2011-2022 走看看