網站首頁 編程語言 正文
Ubuntu 安裝ccache
- sudo apt-get install ccache
- 安裝完后確認安裝執行which ccache
$ which ccache
/usr/bin/ccache
3.在 ~/.bashrc 或者 ~/.zshrc文件內追加以下內容
# ccache
export USE_CCACHE=1
export CCACHE_SLOPPINESS=file_macro,include_file_mtime,time_macros
export CCACHE_UMASK=002
source /.bashrc或者/.zshrc
4. ccache默認設置的5G磁盤空間,正常來說夠用,如果擔心不夠可以改大一些,
ccache -M 30G
5. 通過版本確認安裝成功
$ ccache --version
ccache version 3.4.1
Copyright (C) 2002-2007 Andrew Tridgell
Copyright (C) 2009-2018 Joel Rosdahl
6.可以通過ccache -s查看當前配置
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測試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目錄內建立 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目錄執行cmake ..
打印顯示 -- use ccache 表示啟用ccache,但需要注意的事,每個項目在第一次啟用ccache時,不會加快編譯速度,而是把編譯緩存保存到 /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命令來記錄編譯耗費的時間
/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目錄內的所有文件
7.重新 cmake ..
8.使用 /usr/bin/time命令來記錄編譯耗費的時間
/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
原文鏈接:https://www.cnblogs.com/jiangyibo/p/16516932.html
相關推薦
- 2021-11-21 CentOS7環境中DHCP配置教程_Linux
- 2022-04-27 Python線程之線程安全的隊列Queue_python
- 2022-05-17 ubuntu切換python版本解決語法不匹配問題(SyntaxError: invalid syn
- 2022-06-24 C#中緩存System.Web.Caching用法總結_C#教程
- 2022-05-17 IDEA使用Tomcat
- 2022-11-25 golang?實現時間滑動窗口的示例代碼_Golang
- 2022-10-01 使用flask如何獲取post請求參數_python
- 2022-06-11 C#實現文件Move和Copy操作_C#教程
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支