猫博

猫也博客-c++ kernel ddk ifs
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

令人吃惊的完成端口Copy速度!

Posted on 2004-02-27 15:32  catlog  阅读(2597)  评论(5编辑  收藏  举报

今天把SDK的UnBufCpy的例子编译了一下,令人吃惊的是在我的机器(P42.66,512M Ram 80G7200HDD)上的Copy速度竟然是4085.11M/s

看了看代码,原来完成端口是如此的NB。

只是代码中的注释:

Abstract:

    This single-threaded version shows how to multiplex I/O to a number of files with
    a single thread. This is the most efficient mechanism if you do not need the
    asynchronous completion model that the dual-threaded version offers.

    Only one thread and one I/O completion port is used. The file handles for the
    source and destination file are both associated with the same port.  The
    thread starts off by posting a number of overlapped
    reads from the source file.  It then waits on the I/O completion port.
    Whenever a read completes, it immediately turns it around into a write to
    the destination file. Whenever a write completes, it immediately posts the
    next read from the source file.

    Thread 1
       |
       |
    kick off a few
    overlapped reads
       |
       |
  ->GetQueuedCompletionStatus(WritePort) <-----------
  |    |                                            |
  |    |-------------------------------             |
  |    |                              |             |
  | write has completed,      read has completed,   |
  | kick off another          kick off the write.   |
  | read                              |             |
  |    |                              |             |
  |____|                              |_____________|

比FileMap的方式还要快几个数量级

看来MS SDK中还是又很多宝的