I just want to know how fast can C++ generate data? For example, I have a downstream device that is connected to my pc via a Gigabit Ethernet, and I have to generate some pattern and send it over the Gigabit interface.
I was curious if there is a way that I can see how fast I can generate data? I was curious if I can exercise a good portion of the bandwidth ! for example, sending about 600 Mbits/sec.
How do I find out, first, whether I can do this with C/C++, and, second, how do I know how fast I am sending data?
Let's say It is not even a random data. Let say I have a fixed pattern, for example (0xFFFFFFFF), and I send this data over and over.
I may need to rephrase my question. What I am trying to ask is that even if you are sending the same data over and over again, and that is all your Code does, and considering all the other multi-tasking overhead that CPU is handling, can I achieve a rate of 600Mbits/s-700Mbits/s over the Ethernet?
Because I am thinking this is a fairly fast rate for C/C++ to handle on a typical CPU !!
What I am trying to ask is that even if you are sending the same data over and over again, and that is all your Code does, and considering all the other multi-tasking overhead that CPU is handling, can I achieve a rate of 600Mbits/s-700Mbits/s over the Ethernet?
A typical CPU will have no problem filling a 600-700 Mbit pipe, in regards to IO ability.
What I think you should really do is get a high resolution timer like QueryPerformanceCounter (Windows) and measure the time it takes your app to generate the data (store it in memory so the disk does not lower your results). Then, you will know "how fast can C++ generate [your] data [on your computer]".
and, second, how do I know how fast I am sending data?
Something like this I think, not sure if you are asking something different because this is pretty standard.
1) know how much data you are about to send (szData) - otherwise you have to count while you send
2) store current time (startTime)
3) execute the data send process
4) store current time (endTime)
5) szData / (endTime - startTime) = data sent over time interval
Thanks for the reply. I see what you mean, and I will try this.
By the way, is there any lower level IO operation in C other than fwrite/fread?
Because, I remember that in the past, there was a limit on the transfer size of the fwrite/fread functions.
I am not sure, but I think it was something close to 130-200 MBytes per a function call.
If I were to send more data than that (with every fwrite function call), then I would get a stack overflow errors.