异步操作的性能 [英] Asynchronous operations performance

查看:133
本文介绍了异步操作的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个异步编程在.NET中长时间运行的操作执行过程中节省的线程。该的FileStream 类可以设置为允许异步操作,即可以在不使用几乎任何线程中运行(例如)复制操作。令我惊讶的是,我发现,运行异步流副本执行,不仅速度慢,而且还采用了比同步复制流相当于更强的处理能力。

One of the features of asynchronous programming in .NET is saving threads during long running operation execution. The FileStream class can be setup to allow asynchronous operations, that allows running (e.g.) a copy operation without virtually using any threads. To my surprise, I found that running asynchronous stream copy performs not only slower, but also uses more processing power than synchronous stream copy equivalent.

时有任何基准测试都比较同步VS异步操作执行(文件,网络等)?它是否真的有意义执行异步操作,而不是跨越单独的线程,并在服务器环境中执行同步操作,如果异步操作倍同步1慢?

Is there any benchmark tests were done to compare a synchronous vs asynchronous operation execution (file, network, etc.)? Does it really make sense to perform an asynchronous operation instead of spanning separate thread and perform synchronous operation in server environment if the asynchronous operation is times slower than the synchronous one?

推荐答案

其实,在何种条件下文件I / O会的实际上的是异步是相当具体,甚至在本地的Win32水平。请参见这篇文章了解更多详情。

Actually, the conditions under which file i/o will be actually be asynchronous are rather specific, even at the native Win32 level. See this article for more details.

这篇关于异步操作的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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