欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用cache加快編譯速度的命令詳解

 更新時(shí)間:2022年07月25日 12:06:53   作者:皮皮醬  
這篇文章主要介紹了使用cache加快編譯速度的方法,主要講解在Ubuntu 安裝ccache,使用libzmq測(cè)試ccache的相關(guān)知識(shí),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

Ubuntu 安裝ccache

  1. sudo apt-get install ccache
  2. 安裝完后確認(rèn)安裝執(zhí)行which ccache
$ which ccache
/usr/bin/ccache

3.在 ~/.bashrc 或者 ~/.zshrc文件內(nèi)追加以下內(nèi)容

# ccache
export USE_CCACHE=1
export CCACHE_SLOPPINESS=file_macro,include_file_mtime,time_macros
export CCACHE_UMASK=002

source /.bashrc或者/.zshrc
4. ccache默認(rèn)設(shè)置的5G磁盤空間,正常來說夠用,如果擔(dān)心不夠可以改大一些,
ccache -M 30G
5. 通過版本確認(rèn)安裝成功

$ ccache --version
ccache version 3.4.1
Copyright (C) 2002-2007 Andrew Tridgell
Copyright (C) 2009-2018 Joel Rosdahl

6.可以通過ccache -s查看當(dāng)前配置

cache directory                     /home/username/.ccache
primary config                      /home/username/.ccache/ccache.conf
secondary config      (readonly)    /etc/ccache.conf
stats zero time                     Fri Jul 22 16:15:40 2022
cache hit (direct)                  4186
cache hit (preprocessed)             875
cache miss                          1069
cache hit rate                      82.56 %
called for link                      653
cleanups performed                     0
files in cache                      3209
cache size                          159.3 MB
max cache size                      30.0 GB

使用libzmq測(cè)試ccache

1.通過github下載 libzmq的源碼

$ git clone  https://github.com/zeromq/libzmq.git
Cloning into 'libzmq'...
remote: Enumerating objects: 43791, done.
remote: Counting objects: 100% (36/36), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 43791 (delta 11), reused 24 (delta 8), pack-reused 43755
Receiving objects: 100% (43791/43791), 21.91 MiB | 1.03 MiB/s, done.
Resolving deltas: 100% (31951/31951), done.

2.在 libzmq目錄內(nèi)建立 build目錄

3.修改CMakeLists.txt, '+'后面的代表新增

──────┬───────────────────────────────────────────────────────────────────────────────────────
       │ File: CMakeLists.txt
───────┼──────────────────────────────────────────────────────────────────────────────────────
   1   │ # CMake build script for ZeroMQ
   2   │ project(ZeroMQ)
   3   │ 
   4   │ if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
   5   │   cmake_minimum_required(VERSION 3.0.2)
   6   │ else()
   7   │   cmake_minimum_required(VERSION 2.8.12)
   8   │ endif()
   9   │ 
  10 + │ find_program(CCACHE_FOUND ccache)
  11 + │ if(CCACHE_FOUND)
  12 + │     set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  13 + │     set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
  14 + │     message(STATUS "use ccache")
  15 + │ endif(CCACHE_FOUND)
  16 + │ 
  17   │ include(CheckIncludeFiles)

4.在build目錄執(zhí)行cmake ..
打印顯示 -- use ccache 表示啟用ccache,但需要注意的事,每個(gè)項(xiàng)目在第一次啟用ccache時(shí),不會(huì)加快編譯速度,而是把編譯緩存保存到 /home/username/.ccache目錄,供以后編譯使用

$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- use ccache
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE 
...

5.使用 /usr/bin/time命令來記錄編譯耗費(fèi)的時(shí)間

/usr/bin/time make -j3
result:
48.79user 14.25system 0:21.60elapsed 291%CPU (0avgtext+0avgdata 176036maxresident)k
0inputs+282248outputs (0major+2406923minor)pagefaults 0swaps

6.rm -rf * 刪除build目錄內(nèi)的所有文件

7.重新 cmake ..

8.使用 /usr/bin/time命令來記錄編譯耗費(fèi)的時(shí)間

/usr/bin/time make -j3
result:
2.78user 2.42system 0:02.15elapsed 241%CPU (0avgtext+0avgdata 23736maxresident)k
0inputs+21744outputs (0major+232849minor)pagefaults 0swaps

到此這篇關(guān)于使用cache加快編譯速度的文章就介紹到這了,更多相關(guān)cache加快編譯速度內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Systemd?入門實(shí)戰(zhàn)教程

    Systemd?入門實(shí)戰(zhàn)教程

    這篇文章主要介紹了Systemd?入門實(shí)戰(zhàn)教程,介紹如何使用它完成一些基本的任務(wù),本文結(jié)合示例代碼給大家講解的非常詳細(xì),需要的朋友可以參考下
    2022-12-12
  • 多端登錄如何實(shí)現(xiàn)踢人下線需求實(shí)現(xiàn)

    多端登錄如何實(shí)現(xiàn)踢人下線需求實(shí)現(xiàn)

    這篇文章主要為大家介紹了多端登錄如何實(shí)現(xiàn)踢人下線的需求實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05
  • 詳解git merge命令應(yīng)用的三種情景

    詳解git merge命令應(yīng)用的三種情景

    這篇文章主要介紹了詳解git merge命令應(yīng)用的三種情景,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-08
  • 2022年最新Typora的破解方法

    2022年最新Typora的破解方法

    Typora是一款支持實(shí)時(shí)預(yù)覽的Markdown文本編輯器,支持即時(shí)渲染技術(shù),這也是與其他Markdown編輯器最顯著的區(qū)別,今天通過本文給大家分享2022年最新Typora的破解方法,感興趣的朋友一起看看吧
    2022-09-09
  • kafka不支持讀寫分離原理分析

    kafka不支持讀寫分離原理分析

    這篇文章主要為大家介紹了kafka不支持讀寫分離原理分析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-11-11
  • chatGPT使用及注冊(cè)過程中常見的一些錯(cuò)誤解決方法(所有報(bào)錯(cuò)匯總)

    chatGPT使用及注冊(cè)過程中常見的一些錯(cuò)誤解決方法(所有報(bào)錯(cuò)匯總)

    這篇文章主要介紹了chatGPT注冊(cè)報(bào)錯(cuò)及使用過程中報(bào)錯(cuò)匯總及解決方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-02-02
  • tcp、udp、ip協(xié)議分析_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    tcp、udp、ip協(xié)議分析_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    這篇文章主要為大家詳細(xì)介紹了tcp、udp、ip協(xié)議分析的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • 算法系列15天速成 第七天 線性表【上】

    算法系列15天速成 第七天 線性表【上】

    人活在社會(huì)上不可能孤立,比如跟美女有著千絲萬縷的關(guān)系,有的是一對(duì)一,有的是一對(duì)多,有的是多對(duì)多
    2013-11-11
  • 詳解Git建立本地倉庫的兩種方法

    詳解Git建立本地倉庫的兩種方法

    這篇文章主要介紹了詳解Git建立本地倉庫的兩種方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-08-08
  • 如何解決vscode中ESLint和prettier沖突問題

    如何解決vscode中ESLint和prettier沖突問題

    這篇文章主要給大家介紹了關(guān)于如何解決vscode中ESLint和prettier沖突問題的相關(guān)資料,ESLint和Prettier之間可能會(huì)發(fā)生沖突,因?yàn)樗鼈兌际怯糜诖a規(guī)范化的工具,但它們的規(guī)則和格式化方式可能不同,需要的朋友可以參考下
    2023-11-11

最新評(píng)論