Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Buffer.BlockCopy vs unsafe byte* pointer copy

which one has better performance when copy a block of byte?

like image 438
Benny Avatar asked Mar 01 '10 04:03

Benny


2 Answers

Buffer.BlockCopy is pretty optimised - it is basically a wrapper over a raw mem-copy; so it should be pretty fast (and avoids messing with pointers and unsafe code). It should be the default. You could of course measure it each way...

like image 180
Marc Gravell Avatar answered Nov 02 '22 16:11

Marc Gravell


Handling of Large Byte Arrays at http://www.codeproject.com/KB/dotnet/Large_Byte_Array_handling.aspx documents performance versus various methods, include the methods in your question.

like image 34
AMissico Avatar answered Nov 02 '22 17:11

AMissico