Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
Re: Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods [message #30603 is a reply to message #30599] Tue, 11 January 2011 16:11 Go to previous messageGo to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

mirek wrote on Tue, 11 January 2011 15:49

We have

Handle GetHandle() const { return handle; }

but no equivalent for thread ID (whereas we have both as static method).



GetHandle is not a static method. GetHandle and GetCurrentHandle are different methods.

Other Idea:
------
To demonstrate that Mirek proposed (customized) a more faster than my proposed (API) I have created a simple test running in threads:
void WorkerThread(DivisorsInfo f)
{
	char _l[1000];
	Thread::Id id_api;
	Thread::IdCustom id_custom;
	
	TimeStop v_timer;
	
	v_timer.Reset();
	for(int i=0;i<100000000;++i){
		id_custom = Thread::GetCurrentIdCustom();
	}
	dword v_time_cust = v_timer.Elapsed();
	
	v_timer.Reset();
	for(int i=0;i<100000000;++i){
		id_api = Thread::GetCurrentId();
	}
	dword v_time_api1 = v_timer.Elapsed();
	
	sprintf(_l, "Run Thread: %X. api time %u, custom time %u", Thread::GetCurrentIdCustom(), v_time_api1, v_time_cust);
}


and restul under linux (Ubuntu):
Run Thread: B34EEF34. api time 0.991, custom time 1.088. custom realization are faster 0.910846 times
Run Thread: B2CEBF34. api time 1.455, custom time 1.080. custom realization are faster 1.347222 times
Run Thread: B24E8F34. api time 1.862, custom time 0.680. custom realization are faster 2.738235 times
Run Thread: B1CD4F34. api time 2.133, custom time 0.927. custom realization are faster 2.300971 times
Run Thread: B0CAFF34. api time 2.223, custom time 0.698. custom realization are faster 3.184814 times
Run Thread: B14C3F34. api time 2.234, custom time 0.903. custom realization are faster 2.473976 times
Run Thread: B049BF34. api time 2.192, custom time 0.648. custom realization are faster 3.382716 times
Run Thread: AFC87F34. api time 2.030, custom time 0.573. custom realization are faster 3.542757 times


and same code under windows xp
Run Thread: 162229. api time 0.672, custom time 0.390. custom realization are faster 1.723077 times
Run Thread: 167561. api time 0.860, custom time 0.984. custom realization are faster 0.873984 times
Run Thread: 162229. api time 1.219, custom time 1.156. custom realization are faster 1.054498 times
Run Thread: 171BD1. api time 1.265, custom time 0.735. custom realization are faster 1.721088 times
Run Thread: 16C899. api time 1.594, custom time 0.890. custom realization are faster 1.791011 times
Run Thread: 176F09. api time 1.485, custom time 0.578. custom realization are faster 2.569204 times
Run Thread: 17C241. api time 1.485, custom time 0.437. custom realization are faster 3.398169 times

In the end: Mirek realization are approximative 2 times faster than API functionality.
Mirek, can you add your proposed functionality?

[Updated on: Tue, 11 January 2011 17:04]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: CppBase/Parser.cpp patch (SVN r2960)
Next Topic: virtual void Ctrl::PaintOver(Draw& w) new method
Goto Forum:
  


Current Time: Fri May 17 19:58:15 CEST 2024

Total time taken to generate the page: 0.02606 seconds