Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Cycle Count


Reply
 
Thread Tools Display Modes
  #1  
Old 03-31-2003, 12:53 PM
MasamuneXGP's Avatar
MasamuneXGP MasamuneXGP is offline
Centurion
 
Join Date: Nov 2002
Location: NJ
Posts: 176
Default Cycle Count


You know how some VB functions take longer than others? Like InStr() takes a lot longer than Mid(), division takes longer than multiplication, etc... Is there a list somewhere online that lists exactly how long each VB function takes (cycles, I believe, is the measurement) so that I could refrence it when trying to optimize for speed?
__________________
You are just a puppet... you have no heart... and cannot feel any pain...
--Sephiroth
Reply With Quote
  #2  
Old 03-31-2003, 12:58 PM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

Comparing InStr to Mid$ is like comparing apples to oranges. They do completely different things.
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #3  
Old 03-31-2003, 01:00 PM
MasamuneXGP's Avatar
MasamuneXGP MasamuneXGP is offline
Centurion
 
Join Date: Nov 2002
Location: NJ
Posts: 176
Default

Yeah, I know that, but do you deny that InStr takes longer? It was just an example. I'm not trying to decide which one of those to use, I'm just looking for the cycle counts of those and other functions.
__________________
You are just a puppet... you have no heart... and cannot feel any pain...
--Sephiroth
Reply With Quote
  #4  
Old 03-31-2003, 01:07 PM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

Yes I deny that. The time taken by each function depends on the parameters you pass to it. Would you say that cars go faster than motorcycles? Now if you were comparing Mid to Mid$ then yes I would be able to say Mid$ is faster, because they both do the same thing except Mid$ returns a string rather than a variant.

When it comes to operators, yes division (but not integer division) is slower than multiplication which is slower than subtraction which is slower than addition. So if you want to double a number, add it to itself rather than multiplying it by 2.

When it comes to logical operators, Xor, Imp and Eqv are slower than And and Or which are about the same.

Functions and subs are slower than inline code, Long is the fastest datatype to work with, and there are other 'tricks' too.

If you want the actual cycle times for every possible instruction you'd have to know the actual chip architechture.
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing

Last edited by Squirm; 03-31-2003 at 01:29 PM.
Reply With Quote
  #5  
Old 03-31-2003, 01:20 PM
MasamuneXGP's Avatar
MasamuneXGP MasamuneXGP is offline
Centurion
 
Join Date: Nov 2002
Location: NJ
Posts: 176
Default

Alright, so the actual cycle times isn't happening... but is there a site that documents those kind of tricks? For instance, I didn't know that Mid$ is faster... Do you know of a site that says something like "This is faster than this but slower than this"
__________________
You are just a puppet... you have no heart... and cannot feel any pain...
--Sephiroth
Reply With Quote
  #6  
Old 03-31-2003, 01:27 PM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

If you're a true speed freak, you can even ditch VB's native functions for faster alternatives. One excellent site for this is VBSpeed:

http://www.xbeat.net/vbspeed/index.htm

Edit: Doesn't seem to be up at the moment..
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
  #7  
Old 03-31-2003, 01:44 PM
MasamuneXGP's Avatar
MasamuneXGP MasamuneXGP is offline
Centurion
 
Join Date: Nov 2002
Location: NJ
Posts: 176
Default

Sound interesting... I'll be sure to check back when it's up...
__________________
You are just a puppet... you have no heart... and cannot feel any pain...
--Sephiroth
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Indexing a big file MaxdC General 10 09-06-2002 10:19 PM
Your Opinion on Post Count Xilica2k2 Tech Discussions 38 06-07-2002 06:42 PM
Count Functions mjoyeux Word, PowerPoint, Outlook, and Other Office Products 2 12-12-2001 03:05 PM
Pausing VBA after a Shell Command matt_wendling Word, PowerPoint, Outlook, and Other Office Products 10 10-10-2001 09:07 AM
Help creating a count file on a server.. smb10 General 1 06-26-2001 09:53 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->