Certainly, getting 200 random numbers from a single call will be faster than getting 200 random numbers from 200 different calls. It might even be many times faster. But it's likely that you're talking a difference of milliseconds. So it might not be worth doing. Will the difference of a few milliseconds make a noticeable difference to the overall performance of your application?
If you do decide to do it, you probably don't want to mess with vector
, but rather with UINT32[]
. Marshaling a vector
between C# and C++ would be difficult at best. For all practical purposes, impossible.
See Marshaling Different Types of Arrays for examples of how to marshal arrays.
You'll probably want to allocate the array in C# and pass it along with the size to the C++ function. That way, you don't have to worry about deallocating the memory. If you have the C++ code allocate the array and return it, then the C# code will have to call a C++ function to deallocate the memory.