|
|
Home » Community » Coffee corner » Thoughts about alternative approach to multithreading
Re: Thoughts about alternative approach to multithreading [message #19130 is a reply to message #18684] |
Fri, 14 November 2008 10:09 |
Mindtraveller
Messages: 917 Registered: August 2007 Location: Russia, Moscow rgn.
|
Experienced Contributor |
|
|
OK, I`d like to inform on some progress on "alternative" multithreading. It looks like I finally managed to figure how to apply it to U++ correctly (even in previous example). I`ll describe it as soon as class is ready and tested.
For now I`ve made little investigation on callbacks efficiency as I`d like to use them in my implementation. Some simple test was made:#include <Core/Core.h>
#include <math.h>
using namespace Upp;
class TestClass
{
public:
void func(int a, int b)
{
int c = a + b*b;
double xx = sin(a+b*1.34-3.14159252596428);
double yy = cos((double) (b-a));
x += ceil(xx*yy*(c-(b << 4)+(a*b)));
}
private:
int x;
};
CONSOLE_APP_MAIN
{
TestClass tc;
Callback2<int,int> cb = callback(&tc, &TestClass::func);
dword cnt = 0;
for (int j=0; j<50; ++j)
{
Cout() << FormatInt(j) << " ";
dword t1 = GetTickCount();
for (int i=0; i<2000000; ++i)
{
cb(100,500);
//tc.func(100, 500);
}
cnt += GetTickCount()-t1;
Sleep(1500);
}
Cout() << "\n" << FormatInt(cnt/j);
}
Averaged values were calculated for three cases:
1) Plain call
inside loop
2) Callback call
inside loop
3) Callback stack variable creation+call+destruction
Callback2<int,int> cb = callback(&tc, &TestClass::func);
cb(100,500);
inside loop
On my PC I have these values:
1) 594
2) 592
3) 728
Conclusion: U++ callbacks are very efficient. Even for simple functions it takes very small tradeoff to use callbacks instead of plain member function calls. Creating and destroying of callback stack variable takes some time. Not very big though but it is better to avoid it.
Investigation continues.
|
|
|
|
|
Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mr_ped on Tue, 14 October 2008 08:27
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Wed, 15 October 2008 11:59
|
|
|
Re: Thoughts about alternative approach to multithreading
By: zsolt on Wed, 15 October 2008 21:49
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: zsolt on Thu, 16 October 2008 11:38
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Thu, 16 October 2008 15:04
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Fri, 14 November 2008 10:15
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Tue, 18 November 2008 20:05
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Wed, 19 November 2008 10:39
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Wed, 19 November 2008 19:38
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Thu, 20 November 2008 10:42
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Fri, 03 July 2009 18:49
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Sun, 05 July 2009 22:08
|
|
|
Re: Thoughts about alternative approach to multithreading
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Sun, 12 July 2009 08:37
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mirek on Sun, 05 July 2009 22:10
|
|
|
Re: Thoughts about alternative approach to multithreading
By: mr_ped on Tue, 18 November 2008 09:05
|
Goto Forum:
Current Time: Sat Jun 01 18:15:06 CEST 2024
Total time taken to generate the page: 0.02500 seconds
|
|
|