一次C#和C++的实际应用性能比较(C++允许我们使用任何手段来提高效率,只要愿意做出足够的努力)
简单的说C#的设计目标之一就是可以使简单直观的代码具有较高的效率,而且它确实实现了这个目标;而C++允许我们使用任何手段来提高效率,只要愿意做出足够的努力。
原文:
A few years ago, Rico Mariani (at Microsoft) did really interesting performance comparison between C# and C++.
It started when Raymond Chen (one of the most important engineers at Microsoft, and in the CS universe generally) wrote a Chinese/English dictionary application in C++ to illustrate his process for optimizing C++ code. He started with a simple, intuitive version of the code, and then he incrementally profiled and optimized the bottlenecks until he was happy with the performance.
Rico Mariani took a similar tack, writing a simple, intuitive version in C#, and then optimizing its bottlenecks.
Surprisingly, Mariani's original C# implementation is almost ten times as fast as Chen's original C++ implementation, without having to resort to any counterintuitive hacks.
Eventually, Chen rewrote the file I/O library, implemented his own string class, and used a custom memory allocator. Only AFTER jumping through all those hoops, the C++ version was about twice as fast as the C# version.
The moral of the story is that C++ gives you the tools to write blazingly fast software, if you're willing to do a lot of non-standard programming, and use a LOT of hacks.
C#, on the other hand, lets you write really really fast software right out of the gate, without resorting to any oddball shenanigans. But if you want to reach maximum possible performance, you will hit a wall sooner with C# than you would with C++. Additionally, a piece of software in C# will almost always have greater memory requirements than an equivalent C++ program.
There's a summary of the story on Coding Horror, here:
And you can read the whole play-by-play, here (follow all the links at the top of the page):
BenjiSmith
Saturday, December 08, 2007
http://blog.csdn.net/nightmare/article/details/1932497
一次C#和C++的实际应用性能比较(C++允许我们使用任何手段来提高效率,只要愿意做出足够的努力)的更多相关文章
- In-Memory:内存数据库
在逝去的2016后半年,由于项目需要支持数据的快速更新和多用户的高并发负载,我试水SQL Server 2016的In-Memory OLTP,创建内存数据库实现项目的负载需求,现在项目接近尾声,系统 ...
- 01.SQLServer性能优化之---水平分库扩展
汇总篇:http://www.cnblogs.com/dunitian/p/4822808.html#tsql 第一次引入文件组的概念:http://www.cnblogs.com/dunitian/ ...
- 避免重复造轮子的UI自动化测试框架开发
一懒起来就好久没更新文章了,其实懒也还是因为忙,今年上半年的加班赶上了去年一年的加班,加班不息啊,好了吐槽完就写写一直打算继续的自动化开发 目前各种UI测试框架层出不穷,但是万变不离其宗,驱动PC浏览 ...
- 关于DOM的操作以及性能优化问题-重绘重排
写在前面: 大家都知道DOM的操作很昂贵. 然后贵在什么地方呢? 一.访问DOM元素 二.修改DOM引起的重绘重排 一.访问DOM 像书上的比喻:把DOM和JavaScript(这里指ECMScri ...
- Angular2学习笔记(1)
Angular2学习笔记(1) 1. 写在前面 之前基于Electron写过一个Markdown编辑器.就其功能而言,主要功能已经实现,一些小的不影响使用的功能由于时间关系还没有完成:但就代码而言,之 ...
- 故障重现(内存篇2),JAVA内存不足导致频繁回收和swap引起的性能问题
背景起因: 记起以前的另一次也是关于内存的调优分享下 有个系统平时运行非常稳定运行(没经历过大并发考验),然而在一次活动后,人数并发一上来后,系统开始卡. 我按经验开始调优,在每个关键步骤的加入如 ...
- Fis3前端工程化之项目实战
Fis3项目 项目目录结构: E:. │ .gitignore │ fis-conf.js │ index.html │ package.json │ README.md │ ├─material │ ...
- 【AR实验室】mulberryAR : ORBSLAM2+VVSION
本文转载请注明出处 —— polobymulberry-博客园 0x00 - 前言 mulberryAR是我业余时间弄的一个AR引擎,目前主要支持单目视觉SLAM+3D渲染,并且支持iOS端,但是该引 ...
- App开发:模拟服务器数据接口 - MockApi
为了方便app开发过程中,不受服务器接口的限制,便于客户端功能的快速测试,可以在客户端实现一个模拟服务器数据接口的MockApi模块.本篇文章就尝试为使用gradle的android项目设计实现Moc ...
- Vue.js 和 MVVM 小细节
MVVM 是Model-View-ViewModel 的缩写,它是一种基于前端开发的架构模式,其核心是提供对View 和 ViewModel 的双向数据绑定,这使得ViewModel 的状态改变可以自 ...
随机推荐
- Sublime Text3的react代码校验插件
之前写前端一直用的是jshint做语法检查,但jshint不支持JSX语法,为了在React使用,需要用eslint代替它.六月份的时候为了写React Native,编辑器换过Webstorm和VS ...
- 让delphi2010操作界面回到delphi7模式
让delphi2010操作界面回到delphi7模式 在使用delphi2010的过程中,很不习惯它的窗口在一个框框内,感觉很不方便,可能是因为使用delphi7很多年了,已经习惯了delphi7的版 ...
- 使用QuickContactBadge关联联系人
QuickContactBadge继承了ImageView,因此它的本质也是图片,也可以通过android:src属性指定它显示的图片.QuickContackBadge额外功能是:该图片可以关联到手 ...
- three.js 初学小示例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Gamma 函数及其应用
1. Γ(⋅) 函数定义 Γ(α)=∫∞0tα−1e−tdt 可知以下基本性质: Γ(α+1)=αΓ(α)(分部积分法) Γ(1)=1 ⇒ Γ(n+1)=n! Γ(12)=π√ 2. 常见变形 对于 ...
- 转载来自朱小厮博客的 一文看懂Kafka消息格式的演变
转载来自朱小厮博客的 一文看懂Kafka消息格式的演变 ✎摘要 对于一个成熟的消息中间件而言,消息格式不仅关系到功能维度的扩展,还牵涉到性能维度的优化.随着Kafka的迅猛发展,其消息格式也在 ...
- WinEdt && LaTex(五)—— 内容的排版
1. 无序列表 需要的环境是\begin{itemize} \end{itemize} \begin{itemize} \item hello \item world \end{itemize} 2. ...
- WPF透明窗体制作
原文:WPF透明窗体制作 窗体的样式: <Grid Width="{Binding Width, ElementName=w}" Height="{Binding ...
- c#-WPF string,color,brush之间的转换
原文:c#-WPF string,color,brush之间的转换 String转换成Color string-"ffffff" Color color = (Color)Colo ...
- HDOJ 2189 悼念512四川汶川大地震遇难者——来生一起走 【生成函数】
意甲冠军:没有解释的很清楚. 策略:如果, 这是改变一个简单的生成函数. 这道题做了好久,才明确是那有毛病.还是理解的不够深刻. AC代码: #include<stdio.h> #incl ...