c++ - Calling a function with different number of threads passed to the application -
I have a function that needs to be applied with different threads each time (doing some performance calculations) , So to know when the performance starts deteriorating). The example is given below:
getTime () {return 0; } Int main () {boost :: threadpool :: thread_pool & lt; & Gt; Threads (nThreads); {Threads.schedule (boost :: bind (and meet-time, NTTrade, 1)) for (Junk and JLL; = NLINs; J ++); } Threads.wait (); } Where, nThreads: the value given on the command line
My question is, will it give me the desired result, because it says 'GetTime' function With 'nThreads' each time the loop is accessed by the program? Or do I need some other method to know?
What I really want to do is:
boost :: threadpool :: thread_pool & lt; & Gt; Threads (nThreads); // Start a new thread that calls the "getTime" function (int j = 0; j & lt; = nLines; j ++) {//threads.schedule(boost::index (>get) , NThreads, 1)); Threads Schedule (boost :: bind (and found, 0, enline, pc)); } (Not sure which of the above is correct.)
The getTime () function is to run with a specified number of text files and I give each row for the API, which I want to perform but I have no relation to this question.
I want to call a function with different threads each time and calculate how long it will take to complete each thread. What was the total time taken with 1 thread, what was the total time to complete by 2 thread, etc.
If I understand correctly, then there is something like what you really want to do: / P>
int main () {int nbThreads = 20; Promote: ThreadPool :: thread_pool & lt; & Gt; Threads (nbThreads); (Int thredid = 0; thread id & lt; = nbThreads; ++ threadId) {threads.schedule (getTime); } Threads.wait (); } If I am right, you do not need to promote here.
Note that Boost. Threadpool is not part of Boost (still? This) It will be, but no review date has been made yet.
Comments
Post a Comment