I am developing an application that analyzes financial data in real time. Currently, my main computing cycle has the following design:
long cycle_counter=0; while (process_data) { (analyse data, issue instruction - 5000 lines of straightforwasrd code with computations) cycle_counter++; Thread.Sleep(5); }
When I run this application on my laptop (one Core i5 processor), the cycle runs 200-205 times per second - sort of as expected (unless you worry about why it runs more than 200 times per second).
But when I deploy the application to a "real" workstation, which has 2 6-core Xeon processors and 24 GB of RAM and loads Win7 in about 3 seconds, the application starts the cycle about 67 times per second.
My questions:
Why is this happening?
How can I affect the number of runs per second in this situation?
Are there any better solutions for starting a cycle 200-1000 times per second? Now I'm thinking of simply removing Thread.Sleep () (the way I use it here has been criticized a lot). With 12 cores, I have no problem using a single core just for this loop. But do I have a drawback of such a solution?
Thanks for your ideas.
multithreading c #
user3237591
source share