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(类型萃取
泛型編程編出來的代碼,適用於任何「吻合某種條件限制」的資料型別.這已成為撰寫可復用代碼時的一個重要選擇.然而,總有一些時候,泛型不夠好 — 有時候是因為不同的型別差距過大,難以產生一致的泛化實作版本. ...
随机推荐
- 51,PIC,AVR单片机它们的优点缺点都有哪些?
我有幸接触了几款单片机,并用它们做了一些项目.现在想做个小总结,谈一下自己用各种单片机的感受.仅是个人意见,仁者见仁智者见智. 传统51,我想我就不多说了,适合菜鸟入门,容易上手,价格一般(从性价比方 ...
- AStyle代码格式工具在source insight中的使用
一.AStyle下载路径 Astyle为开源项目,支持C/C++和java的代码格式化 Home Page: http://astyle.sourceforge.net/ Project Page: ...
- Android开源项目发现--- 效率开发工具篇(持续更新)
1.Json2Java 根据JSon数据自动生成对应的Java实体类,还支持Parcel.Gson Annotations对应代码自动生成.期待后续的提取父类以及多url构建整个工程的功能 项目地址: ...
- JVM参数配置大全
前阵子遇到几个面试题都是关于对Java内存控制的,因此从网上找到这篇文章,希望自己对Java的内存分配有重新的认识 /usr/local/jdk/bin/java -Dresin.home=/usr/ ...
- TCP/IP 邮件的原理
邮件通过SMTP协议来实现,有它的服务器SMTP服务器. 它是怎么在万维网中运行的呢? 我们来看看两个案例,下面的两个图来展示. 案例一: Alice通过传统的邮件服务器发送给Bob,Bob通过HTT ...
- bzoj1041
基于圆的对称性,我们只需要考虑第一象限的整点即可满足条件的x,y都是整数数学上这类问题我们通常用一个量表示另一个量y^2=(r-x)(r+x) (r-x)(r+x)要是完全平方数令d=gcd(r-x ...
- BZOJ3039: 玉蟾宫&wikioi2491 玉蟾宫
3039: 玉蟾宫 Time Limit: 2 Sec Memory Limit: 128 MBSubmit: 430 Solved: 265[Submit][Status] Descriptio ...
- STM32F072B-DISCO 深入研究 USB系统
调试USB例题需要用到2个上位机程序: PC端HID交互程序,提供了VC源程序. 图形方式的按钮输入.LED输出操作: 总线扑捉器: main程序初始化部分很简单: /* Initialize USB ...
- UVa10047 The Monocycle
UVa10047 The Monocycle 链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=19491 (以上摘自htt ...
- ios策略模式应用
策略模式应用大量应用于解决巨型switch-case if-else..... 具体使用方法 : 策略基类(BaseStrategy)包含一个虚算法,所有子类实现虚算法 容器类含有一个指向策略基类的 ...