g++代码编译用选项-O3前后对比,前后执行时间对比如下
g++代码编译用选项-O3前后对比,前后执行时间对比如下
g++ -std=c++11 main.cpp blur.cpp initialize_beliefs.cpp move.cpp normalize.cpp print.cpp sense.cpp zeros.cpp
root@b8da9efe81e4:/home/workspace/optimized_code# ./a.out
number of iterations: 10000
duration milliseconds initialize beliefs 22.599
duration milliseconds sense 16.463
duration milliseconds blur 77.062
duration milliseconds normalize 20.721
duration milliseconds move 31.484
/今早2.13用该条编译器优化看看是否较上条提升了性能
g++ -std=c++11 -O3 main.cpp blur.cpp initialize_beliefs.cpp move.cpp normalize.cpp print.cpp sense.cpp zeros.cpp
//编译优化后的
root@65c825f71a98:/home/workspace/optimized_code# ./a.out
number of iterations: 10000
duration milliseconds initialize beliefs 3.284
duration milliseconds sense 3.972
duration milliseconds blur 26.045
duration milliseconds normalize 2.177
duration milliseconds move 4.634
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
Depending on the target and how GCC was configured, a slightly different set of optimizations may be enabled at each -O level than those listed here. You can invoke GCC with -Q --help=optimizers to find out the exact set of optimizations that are enabled at each level. See Overall Options, for examples.
-O
-O1
-O turns on the following optimization flags:
-fauto-inc-dec -fbranch-count-reg -fcombine-stack-adjustments -fcompare-elim -fcprop-registers -fdce -fdefer-pop -fdelayed-branch -fdse -fforward-propagate -fguess-branch-probability -fif-conversion -fif-conversion2 -finline-functions-called-once -fipa-profile -fipa-pure-const -fipa-reference -fipa-reference-addressable -fmerge-constants -fmove-loop-invariants -fomit-frame-pointer -freorder-blocks -fshrink-wrap -fshrink-wrap-separate -fsplit-wide-types -fssa-backprop -fssa-phiopt -ftree-bit-ccp -ftree-ccp -ftree-ch -ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-phiprop -ftree-pta -ftree-scev-cprop -ftree-sink -ftree-slsr -ftree-sra -ftree-ter -funit-at-a-time
Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to -O, this option increases both compilation time and the performance of the generated code.
-O2 turns on all optimization flags specified by -O. It also turns on the following optimization flags:
-falign-functions -falign-jumps -falign-labels -falign-loops -fcaller-saves -fcode-hoisting -fcrossjumping -fcse-follow-jumps -fcse-skip-blocks -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively -fexpensive-optimizations -ffinite-loops -fgcse -fgcse-lm -fhoist-adjacent-loads -finline-functions -finline-small-functions -findirect-inlining -fipa-bit-cp -fipa-cp -fipa-icf -fipa-ra -fipa-sra -fipa-vrp -fisolate-erroneous-paths-dereference -flra-remat -foptimize-sibling-calls -foptimize-strlen -fpartial-inlining -fpeephole2 -freorder-blocks-algorithm=stc -freorder-blocks-and-partition -freorder-functions -frerun-cse-after-loop -fschedule-insns -fschedule-insns2 -fsched-interblock -fsched-spec -fstore-merging -fstrict-aliasing -fthread-jumps -ftree-builtin-call-dce -ftree-pre -ftree-switch-conversion -ftree-tail-merge -ftree-vrp
Please note the warning under -fgcse about invoking -O2 on programs that use computed gotos.
-O3
Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the following optimization flags:
-fgcse-after-reload -fipa-cp-clone -floop-interchange -floop-unroll-and-jam -fpeel-loops -fpredictive-commoning -fsplit-paths -ftree-loop-distribute-patterns -ftree-loop-distribution -ftree-loop-vectorize -ftree-partial-pre -ftree-slp-vectorize -funswitch-loops -fvect-cost-model -fversion-loops-for-strides
-O0
Reduce compilation time and make debugging produce the expected results. This is the default.
-Os
Optimize for size. -Os enables all -O2 optimizations except those that often increase code size:
-falign-functions -falign-jumps -falign-labels -falign-loops -fprefetch-loop-arrays -freorder-blocks-algorithm=stc
It also enables -finline-functions, causes the compiler to tune for code size rather than execution speed, and performs further optimizations designed to reduce code size.
g++代码编译用选项-O3前后对比,前后执行时间对比如下相关推荐
- 3d打印c语言与g代码混合编程,[转载]三轴运动控制器、串口运动控制器、支持G代码、3D打印机、雕刻、源代码开放、...
串口运动控制器,支持G代码.M代码 3D打印机.雕刻机.激光雕刻.木工雕刻.微型CNC.开源GRBL运动控制平台 电源电压:DC12V-24V CPU:Atmega328P 串口:RS232电平,通信 ...
- 执行引擎的工作过程、Java代码编译和执行的过程、解释器、JIT编译器
执行引擎概述 执行引擎是Java虛拟机核心的组成部分之一. "虚拟机"是-一个相对于"物理机"的概念,这两种机器都有代码执行能力,其区别是物理机的执行引擎是直接 ...
- linux gcc g++编译命令选项
gcc/g++在执行编译工作的时候,总共需要4步 1.预处理,生成.i的文件[预处理器cpp] 2.将预处理后的文件不转换成汇编语言,生成文件.s[编译器egcs] 3.有汇编变为目标代码(机器代码) ...
- Linux代码编译(模式切换、gdb、编译器之间的对比、彩色进度条、rpm与yum区别)
常用工具: 软件包管理工具:yum 编程相关工具:vim.gcc/g++.gdb 项目相关工具:make/Makefile.git 查看软件包:yum list/grep key 安装软件包:yum ...
- gcc/g++ 命令的常用选项
gcc/g++ 命令的常用选项 使用g++编译CPP文件如果用gcc编译C++源文件时,加以下选项:-lstdc++,否则使用了C++操作的文件编译会出错.假如在程序中用到new delete操作,而 ...
- 7. 从0学ARM-GNU伪指令、代码编译,lds使用
<嵌入式工程师到底要不要学习ARM汇编指令?arm学习文章汇总> <到底什么是Cortex.ARMv8.arm架构.ARM指令集.soc?一文帮你梳理基础概念[科普]> 关于A ...
- 内核编译配置选项含义
Linux 2.6.19.x 内核编译配置选项简介 作者:金步国 版权声明 本文作者是一位自由软件爱好者,所以本文虽然不是软件,但是本着 GPL 的精神发布.任何人都可以自由使用.转载.复制和再分发, ...
- g++ linux 编译开栈_linux下使用g++编译cpp工程
C++编程中相关文件后缀 1.单个源文件生成可执行程序 下面是一个保存在文件 helloworld.cpp 中一个简单的C++程序的代码: 1 /*helloworld.cpp*/ 2 #includ ...
- Linux 内核编译配置选项简介(转)
Linux 内核编译配置选项简介 作者:金步国 版权声明 本文作者是一位自由软件爱好者,所以本文虽然不是软件,但是本着 GPL 的精神发布.任何人都可以自由使用.转载.复制和再分发,但必须保留作者署名 ...
最新文章
- day8 动态导入模块、socket进阶
- Codeforces Round #320 (Div. 1) [Bayan Thanks-Round] B. Or Game
- ios加速计(可以用来检测摇动,自定义反应灵敏度)
- Spring:设置日志依赖项
- linux+kill+进程和线程,在LINUX系统中 关于进程和线程终止的问题
- macbook proc 如何设置touch bar 为F键
- 基于JAVA宠物管理系统的设计与实现
- 安卓系统的电视机_再送出一款智能电视、电视盒子、安卓手机通用TV直播软件...
- 1H413000工业机电工程安装技术—— 1H413010机械设备安装技术
- DHT11温湿度传感器(zigbee)
- RadioButtonList功能汇总
- 专访最强夫妻店:“神庙逃亡2”开发背后的故事
- 如何在抖音主页添加官方联系电话?
- 人手必备,策略中最常用的5类Python数据接口
- 51单片机入门模板(STC89C52RC)
- 利用文本编辑器判断dll/exe是否为64位
- 2017秋招-技术岗-恒生电子
- http://club.topsage.com/thread-2203076-1-1.html
- mysql与pandas谁快,pandas和SQL哪个快
- c/c++/易语言驱动内存无痕读写源码-包含易语言调用示例代码
热门文章
- ble串口程序设计流程图_流程图程序设计的步骤
- linux定时器多次,Spring 定时器执行两次
- nginx http转https_Nginx处理访问www域名跳转到不带www域名的配置方法
- class instance java_[Java] Java instanceof 和 Class.isInstance()区别与应用
- 7-20 打印九九口诀表 (C语言)
- 实现php实现价格的排序,php 数组动态添加实现代码(最土团购系统的价格排序)_PHP教程...
- Fiddler小技巧-测试上传文件接口多参数并传情况
- Multithreading in Java
- Array.asList:数组转list时你一定要知道的“陷阱”!
- Unobtrusive JavaScript 不唐突的JavaScript的七条准则