C#性能代理服务器(vs C ++) [英] C# Performance For Proxy Server (vs C++)

查看:164
本文介绍了C#性能代理服务器(vs C ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个简单的http代理服务器,对HTTP头进行一些非常基本的处理(即如果头x == y,do z)。服务器可能需要支持数百个用户。我可以写在C#(很容易)或C ++(更难)的服务器。但是,C#版本的性能是否与C ++版本一样好?

I want to create a simple http proxy server that does some very basic processing on the http headers (i.e. if header x == y, do z). The server may need to support hundreds of users. I can write the server in C# (pretty easy) or c++ (much harder). However, would a C# version have as good of performance as a C++ version? If not, would the difference in performance be big enough that it would not make sense to write it in C#?

推荐答案

你可以在C#在关键瓶颈点使用不安全 C#代码和指针,以使其运行更快。这些行为很像C ++代码,我相信它执行快速

You can use unsafe C# code and pointers in critical bottleneck points to make it run faster. Those behave much like C++ code and I believe it executes as fast.

但是大多数时候,C#是JIT-ted到uber-快速已经,我不相信会有很大的差异,因为每个人都说。

But most of the time, C# is JIT-ted to uber-fast already, I don't believe there will be much differences as with what everyone has said.

但你可能需要考虑的一件事是: (C#)字符串操作比在C ++中有效地使用指针更慢。使用C ++指针比使用CLR字符串有更多的优化技巧。

But one thing you might want to consider is: Managed code (C#) string operations are rather slow compared to using pointers effectively in C++. There are more optimization tricks with C++ pointers than with CLR strings.

我之前做了一些基准测试,但不记得我把它们放在哪里了。

I think I have done some benchmarks before, but can't remember where I've put them.

这篇关于C#性能代理服务器(vs C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆