 |
 |

03-31-2003, 12:53 PM
|
 |
Centurion
|
|
Join Date: Nov 2002
Location: NJ
Posts: 176
|
|
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
|

03-31-2003, 12:58 PM
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
|
Comparing InStr to Mid$ is like comparing apples to oranges. They do completely different things.
|
|

03-31-2003, 01:00 PM
|
 |
Centurion
|
|
Join Date: Nov 2002
Location: NJ
Posts: 176
|
|
|
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
|

03-31-2003, 01:07 PM
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
|
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.
|
Last edited by Squirm; 03-31-2003 at 01:29 PM.
|

03-31-2003, 01:20 PM
|
 |
Centurion
|
|
Join Date: Nov 2002
Location: NJ
Posts: 176
|
|
|
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
|

03-31-2003, 01:27 PM
|
 |
Political Coder
Retired Moderator * Guru *
|
|
Join Date: Mar 2001
Location: London, England
Posts: 8,037
|
|
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..
|
|

03-31-2003, 01:44 PM
|
 |
Centurion
|
|
Join Date: Nov 2002
Location: NJ
Posts: 176
|
|
|
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
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|