Performance tips
来源:互联网 发布:算法 第4版 豆瓣 编辑:程序博客网 时间:2024/05/17 06:39
TIPS
- Remember the 80/20 rule
- 80% of a program spends its time in 20% of the code
- Prefer x += y, to x = x + y
- Use pre-incrementation (++i), instead of post-incrementation (i++)
- This typically applies to any object that has a custom incrementor/decrementor instead of a native type.
- Pre-allocatation of memory will help memory fragmentation
- Don't use dynamic_cast, its a run-time cast operator
- Avoid using printf (printf, sprintf, strftime) functions where alternatives are possible
- Evaluate once, use many times
- In loops if a value doesn't change, evaluate it outside the loop ( don't trust the compiler to optimise )
- Use Just-In-Time (lazy) evaluation where appropriate
- Don't evaluate something if it will won't be used
- i.e. evaluate just before using
- Use Object Caching to pre-allocate memory and objects
- i.e. by overriding new and delete operators
- Helps not only in performance but also memory fragementation
- Helps greatly in a system with various different sizes of objects
- Use reference-counting and smart-pointers to avoid excessive memory allocation
- Initialise objects instead of assignement
- Don't use 'int a; a = 2;'
- Use 'int a = 2;'
- MEB Specific
- There are several system calls made every time round each MEB main loop.
- The MEB is single threaded, hence end->end time is just as important as time of individual components
- System calls
- system() calls are really expensive. If called frequently look into alternatives
- sigprocmask is really bad on Linux/gcc, similarly gettimeofday is very expensive as well
- iostat again is really expensive on Linux/gcc
- Look into alternatives into all system calls.
- Pcap Issues
- Standard implementations usually incur a high overhead due to multiple copies of the data
- Look into alternatives, e.g. PF-RING, etc
- Performance tips
- C++ Performance Tips
- ASP.NET Performance Tips
- Documentum Performance Tips
- Python Performance Tips
- Web Performance Tips
- Java Performance Tips
- Java performance tuning tips
- CUDA Performance Tips
- WPF Performance Tips
- 6 Python Performance Tips
- 6 Python Performance Tips
- Android Performance Tips
- Java Performance Tips
- Tips: Disk Performance On FreeBSD
- Top 10 WPF Performance Tips
- Top 84 MySQL Performance Tips
- 7 Tips forImproving MapReduce Performance
- firefox定制文章
- listview中长按事件响应
- Asp.Net分页方法:JQuery插件实现Ajax无刷新分页、AspNetPager分页控件实现分页
- 数据库和 MIDP
- 各种平台下Perl模块的安装方法
- Performance tips
- log4j配置xml方式
- 简单工厂模式
- 从菜鸟到高手的自学linux教程(一)
- js中常见的几种调用ajax的方式
- 浅析request_module内核驱动直接引用用户空间程序/sbin/modprobe
- Linux 从源码编译安装 OpenSSL
- 直接插入排序、折半插入排序、2-路插入排序实现
- 【Android】使用ConnectivityManager与NetworkInfo实现判断当前网络环境是否可用