Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 7, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Use Explicit Object Types for Speed

It is much faster to use explicit object data types instead of generic ones. In this test that simply sets an object's public variable, the generic object takes more than 150 times longer than the specific object:

 Private Sub Command1_Click()
Dim specific As MyClass
Dim generic As Object
Dim start_time As Single
Dim stop_time As Single
Dim i As Long
	Set specific = New MyClass
	Set generic = New MyClass
	start_time = Timer
	For i = 1 To 100000
		specific.value = i
	Next i
	stop_time = Timer
	MsgBox Format$(stop_time - start_time)
	start_time = Timer
	For i = 1 To 100000
		generic.value = i
	Next i
	stop_time = Timer
	MsgBox Format$(stop_time - start_time)
End Sub
Rod Stephens
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date