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

  • 相关阅读:
    129. Sum Root to Leaf Numbers
    113. Path Sum II
    114. Flatten Binary Tree to Linked List
    112. Path Sum
    100. Same Tree
    300. Longest Increasing Subsequence
    72. Edit Distance
    自定义js标签库
    JS 实现Table相同行的单元格自动合并示例代码
    mysql 高版本only_full_group_by 错误
  • 原文地址:https://www.cnblogs.com/pugna/p/4063342.html
Copyright © 2011-2022 走看看