Premature optimization is the root of all evil.
For all of we programmers,we should always remember that "Premature optimization is the root of all evil". (Ref)
When again,I come back to the 'Data Structure and Algorithm',following the algorithms that the .net provides,using the '.net reflector',I realise that I was too much care about something(for i am not work strict to memory and CPU circle limits).
The issue I posted "Would it cost any extra performance if multiple invoke methods that are overload?" on the forum "Stackoverflow" shows the issue that confused me before.
That issue comes from .net ArrayList class,such as the code below:
public static void Copy(Array sourceArray, Array destinationArray, int length)
{
if (sourceArray == null)
{
throw new ArgumentNullException("sourceArray");
}
if (destinationArray == null)
{
throw new ArgumentNullException("destinationArray");
}
Copy(sourceArray, sourceArray.GetLowerBound(), destinationArray, destinationArray.GetLowerBound(), length, false);
}
it actually calls
Copy(sourceArray, sourceArray.GetLowerBound(), destinationArray, destinationArray.GetLowerBound(), length, false);
internal static extern void Copy(Array sourceArray, int sourceIndex, Array destinationArray, int destinationIndex, int length, bool reliable);
as it is obvious.
The method call between themselves can be 'inlined',or the opitimized by jitter.
And remember that "Premature optimization is the root of all evil". Take much time to think about our own algorithms.
Premature optimization is the root of all evil.的更多相关文章
- JavaScript性能优化
如今主流浏览器都在比拼JavaScript引擎的执行速度,但最终都会达到一个理论极限,即无限接近编译后程序执行速度. 这种情况下决定程序速度的另一个重要因素就是代码本身. 在这里我们会分门别类的介绍J ...
- NoSQL数据库笔谈(转)
NoSQL数据库笔谈 databases , appdir , node , paper颜开 , v0.2 , 2010.2 序 思想篇 CAP 最终一致性 变体 BASE 其他 I/O的五分钟法则 ...
- python笔记-python编程优化:常用原则和技术介绍
本人翻译自<Exper Python Programming> 'Premature optimization is the root of all evil in programming ...
- 一个超复杂的间接递归——C语言初学者代码中的常见错误与瑕疵(6)
问题: 问题出处见 C语言初学者代码中的常见错误与瑕疵(5) . 在该文的最后,曾提到完成的代码还有进一步改进的余地.本文完成了这个改进.所以本文讨论的并不是初学者代码中的常见错误与瑕疵,而是对我自己 ...
- GPU 优化总结
前面说了对我这一年多的工作进行一个总结,由于工作比较紧,加上本人比较懒,一直没能抽出时间来写,最近稍微闲下来了.先写一篇GPU优化的,后续的文章希望能慢慢补齐.这些基本都是我个人优化的实际经验,也参考 ...
- Thinking Clearly about Performance
http://queue.acm.org/detail.cfm?id=1854041 The July/August issue of acmqueue is out now acmqueue is ...
- [翻译]HTML中不知名的语义标签
原文:http://docs.webplatform.org/wiki/tutorials/Lesser_-_known_semantic_elements HTML5中比较常用的语义元素有heade ...
- Code Complete阅读笔记(二)
2015-03-06 328 Unusual Data Types ——You can carry this technique to extremes,putting all the ...
- 侯捷C++ Type traits(类型萃取
泛型編程編出來的代碼,適用於任何「吻合某種條件限制」的資料型別.這已成為撰寫可復用代碼時的一個重要選擇.然而,總有一些時候,泛型不夠好 — 有時候是因為不同的型別差距過大,難以產生一致的泛化實作版本. ...
随机推荐
- bzoj2131
首先不难想到对t排序,有f[i]=max(f[j])+v[i] tj<=ti且abs(pi-pj)/2<=ti-tj;要想优化,肯定从优化转移入手先去绝对值,当pi>=pj时,可得2 ...
- JQuery中如何click中传递参数
代码如下: click(data,fn)中的data其实是json对象,取的时候,只能通过当前的事件源来取,data是默认放在event中的,所以这里的data是eventdata,引用的时候也使用e ...
- 全面理解Java异常的运行机制
1. 引子 try…catch…finally恐怕是大家再熟悉不过的语句了,而且感觉用起来也是很简单,逻辑上似乎也是很容易理解.不过,我亲自体验的“教训”告诉我,这个东西可不是想象中的那么简单.听话. ...
- HTML Meta, http-equiv, Refresh
原文: http://www.lifelaf.com/blog/?p=481 在HTML页面中,如果想实现定时刷新或重定向,我们可以使用meta标签的refresh功能: <!-- 5秒后刷新页 ...
- MySQL生僻字(不常用字)的完整解决方案
查看 MySQL 数据库服务器和数据库字符集 show variables like '%char%'; 查看 MySQL 数据表(table) 的字符集 show table status from ...
- Java IO复习 UDP
客户端: package cn.zyw.javaurl; import java.io.IOException; import java.net.*; /** * Created by zyw on ...
- 部署war包到Tomcat
1. 开发给到一个war包,假设叫 a-b-c.war. 2. 打开Tomcat安装路径 ,假设是“D:\Tomcat\apache-tomcat-7.0.68”,然后进入到 webapps文件夹. ...
- Java GC专家系列2:Java 垃圾回收的监控
这是”成为GC专家系列”文章的第二篇.在第一篇理解Java垃圾回收中我们学习了几种不同的GC算法的处理过程,GC的工作方式,新生代与老年代的区别.到目前为止,你应该已经了解了JDK 7中的5种GC类型 ...
- Properties/Property文件读取(键值均)乱码问题!
方法一:使用native2ascii进行转码,这个不做说明,客户不可能帮你转码的. 方法二:当键是因为时直接getProperty即可,但加载后的propertis对象里的键也是中文乱码,就无法通过g ...
- 创建maven项目出现的问题
右击项目无法显示maven图标,创建的pom.xml无法识别,并且创建maven项目时,一直显示Loading archetype list...