|
-
May 31st, 2000, 03:49 AM
#1
Thread Starter
Frenzied Member
Is there a way to make inline functions in VB?
-
May 31st, 2000, 03:51 AM
#2
What do you mean by "inline"? Built in functions?
-
May 31st, 2000, 03:51 AM
#3
transcendental analytic
Yeah, tell us that, anyone
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 31st, 2000, 03:53 AM
#4
transcendental analytic
Personally, i do that by copying all the function code, but it sux, is there any automatic way to do this
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 31st, 2000, 03:55 AM
#5
You could add refrence to a DLL in your main project template and then when you load it, the DLL will be loaded as well.
-
May 31st, 2000, 04:27 AM
#6
Hyperactive Member
VB needs Macros, like #define in C
-
May 31st, 2000, 04:53 AM
#7
Thread Starter
Frenzied Member
we've got that
or are there other macros you can do in C
I'm sure you can do inline functions in VB because I knew what they were before I learnt C++. I just can't remember how to do them
-
May 31st, 2000, 07:29 AM
#8
Hyperactive Member
you can also do
#define ADDER(A,B) A + B
so if you have X = ADDER(4,5) it gets replaced by the preprocessor with X = 4 + 5.
very sweet, esp. with redundant code and there is no function call overhead.
-
May 31st, 2000, 07:32 AM
#9
Hyperactive Member
In VB there is #Const and #If..#ElseIf.. #End If which gets evaluated at compile time.
-
May 31st, 2000, 07:41 AM
#10
Fanatic Member
I had a look a while back for Inline functions in VB on the MSDN and found nothing, infact I found references to indicate that there was no such thing in VB.
It can add a bit of speed in intensive loops but other than that they're not that important I wouldn't have thought.
Question (Sorry, Sam, I know this is your thread)
Is a function call within a form quicker than a function call to a module? or does it not make a difference?
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 31st, 2000, 08:11 AM
#11
transcendental analytic
i'm going to test that paul, i've noticed functions called to modules are faster than to classes, especially if you have a heavy structure of classes. but i'm not sure about calling a class function inside itself
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 31st, 2000, 08:16 AM
#12
Fanatic Member
classes & Objects in VB have quite a bit over overhead, just remember, where possible try to dim a new object as the object type rather than "AS Object" it's a lot quicker if you're doing it a lot (like in linked lists)
Let me know about your form / vs module tests,
might try it may self so we can compare!
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 31st, 2000, 08:31 AM
#13
Fanatic Member
I just tried it with Subs
Form version, 1,000,000 calls = 0.45 sec
Module version, 1,000,000 calls = 0.26 sec
The sub was very simple, dim an Integer and add 1 to it.
PLUS, for interest
When I add a doevents into the loop after the sub, not in it)
Form version, 1,000,000 calls = 9.65 sec
Module version, 1,000,000 calls = 9.01 sec
(All data averaged from three tries)
in general, modules look quicker by about 0.2 - 0.5 sec per million calls,
or 0.0000002 - 0.0000005 sec per call
you wouldn't normally notice, unless you were looping the call millions of times.
This also gives you an idea how how much inline functions would increase performance (if they existed)
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 31st, 2000, 11:50 AM
#14
Hyperactive Member
Paul was this compiled code or running from the VB IDE?
-
May 31st, 2000, 12:29 PM
#15
Fanatic Member
This was compiled for P6 on a win2k system
PII 350 96mb RAM
I tried it on compiled P5 and the difference was minor but then it doesn't really do anything, if there was more math in the sub then p6 may have made more of a difference.
Might try it again at home, the system there is not only faster but cleaner, lot of **** cloging this NTFS system up.
I imagine the results'll be similar.
Would you like me to try it again in the IDE? not really any point I don't feel
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 31st, 2000, 12:38 PM
#16
Hyperactive Member
Nope. was just wondering.
-
May 31st, 2000, 12:42 PM
#17
Fanatic Member
Checking to see if I was an idiot?

Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 31st, 2000, 12:46 PM
#18
Hyperactive Member
Damn! how did you figure that out? haha 
-
May 31st, 2000, 03:29 PM
#19
transcendental analytic
I did some test and i am a bit uncomfortable with the results with qwerryperformance counter
The first test included 1000 single call procedures, all of them with a normal of 4.5µs each on my Athlon-600.
This was what i was uncomfortable with, that i didn't get your results Paul, you probably included for next loops but uncluding them will just give errordiffusion
The second test included for next loops with 1000 loops with 1000 calls. I got a 15% slower performance for the form calls
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 31st, 2000, 09:21 PM
#20
Fanatic Member
Use more loops, the difference between the call types will increase and if you run it several times you less likely to get CPU interference from the findfast and other processes that like to annoy.
even if you're using that time ticks api you love so much 1000 loops is not enough, try 10,000,000 or 100mil! bring the difference into the world of seconds so that there can be no mistake, you can then see the difference for your self rather than rely on a time period you can't sense.
I just use the Timer method! I don't rely on it to the 1000th of a second (or 100th if the cpu is overloaded) but it'll spot a half second delay to the 100th of a second ok
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 31st, 2000, 10:37 PM
#21
Fanatic Member
Paul,
How did you time the process if you did not have a doevents. The timer event will not fire unless you put a doevents somewhere?
I just tried some tests like yours. Dim an integer and Add one to it. I called this 2,000,000
With doevents it takes about 22 seconds.
Without doevents it takes under a second.
However if i do not have a doevents and run the loop 50,000,000 times the timer event never fires.
Iain, thats with an i by the way!
-
May 31st, 2000, 10:51 PM
#22
Fanatic Member
something like this:
Code:
Dim MyLoop As Long
Dim Timed As Single
Timed = Timer
For MyLoop = 1 to 1000000
Call MySub()
Next
Label1.Caption = Str(Timer - Timed)
Public Sub MySub()
Dim X As Integer
X = X + 1
End Sub
Have one button like that and another with a different named sub in a module. You can format the timer better than this but I'm typing this off the top of my head and I can't remember the params for the Format() function 
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 31st, 2000, 10:56 PM
#23
Fanatic Member
Oh I see what you mean now, You're using a timer control
Lose it and use the code above. The Timer method captures the time as a single since midnight and places it in a variable, then when finished compare the current time to the variable, that way you don't have to worry about the CPU processors preventing an event from firing! (Unless your bios clock stops in which case you're screwed anyway )
Look up "Timer" in the MSDN help
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
May 31st, 2000, 11:04 PM
#24
Fanatic Member
Paul,
Nice one mate 
Got the same sort of results as you.
The Module code took 0.44 seconds
The Form code took 0.66 seconds
I also tried it without explcitly declaring the variable as an integer, so it was a variant.
The module then took 6.9 seconds
The form then took 7 seconds
Shows why it is not a good idea to use variants.
Iain, thats with an i by the way!
-
May 31st, 2000, 11:26 PM
#25
transcendental analytic
WHAT! come on, Fox, have a look at this, they are using the timer function! WHoaa! That crappy function get's you a 60ms diffusion, with gettickcount you get 1ms, and querryperformance about 1µs!
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 31st, 2000, 11:38 PM
#26
Hyperactive Member
I did the same VB benchmarking with VB string operations, casting and passing byRef and byVal
Here are some results from a P2-400 on NT4 compiled with VB6 SP3
Ucase Benchmark 1,000,000x
UCase: 2.94
UCase$: 1.50
UCaseF: 5.81 (This was an API call, someone said it was fast... haha)
StrConv: 10.82
Anyone wanna see more?
-
May 31st, 2000, 11:45 PM
#27
Hyperactive Member
What is gettickcount? sounds perfect for what I need to do.
and Timer is accurate to 10ms not 60ms. I have done a lot of research on this.
-
May 31st, 2000, 11:50 PM
#28
-
Jun 1st, 2000, 12:05 AM
#29
transcendental analytic
A lot of research? MrShickadance, A lot of research without gettickcount? how do you do that?
ARGH, we need Sam Finch! Explain to them, they can't do that with that crappy timer funcion!
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 1st, 2000, 12:19 AM
#30
Thread Starter
Frenzied Member
why is this my job? but no, the only reason I use timer is if I'm using random numbers and I go
to make the randomness a bit more random.
otherwise I use QueryPerformenceCounter, that works in microseconds and it's the most accurate thing on the computer.
-
Jun 1st, 2000, 02:13 AM
#31
Hyperactive Member
kedaman.. a Digitizing Oscilloscope of course. I have to do time critical COM port sends and recieves.. the shortest wait time with Timer is 10ms, I am willing to put money on this!
Sam if you just use Randomize() it's the same as Randomize(Timer)
-
Jun 1st, 2000, 03:18 AM
#32
transcendental analytic
hmmm, may be alot possible you're right but timer function and timer control uses the same timer function, how can it be possible that timer control updates in 60 ms? wouldn't be too sure, i'll go do some tests
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 1st, 2000, 06:25 AM
#33
Fanatic Member
Yawn!!!
I read that the timer control updates in multiples of 30ms and can be slower.
who care's? This is not that time critical (otherwise, sure use GetTickCount) even if it's 60ms increments and my data is out by that much it's not a big deal in this case.
Besides, you can just throw another magnitude of loops a your times become that much more accurate.
I thought we were talking about process speeds, not timers anyway.
(This is were everyone jumps down my throat for not trying to be accurate enough, I'll go and read up on the timer then and get back to you all)
In the mean time, let's test some more performance issues, I like the idea earlier about testing data types, everyone here knows that a Long is faster than an Integer is faster than a single is faster than a double etc but how much faster? Wouldn't it be nice to have a lookup table!!! and what about the byte type? is it faster than an Integer?
Shall we start a new thread on this? (and leave this one to the timer vs gettickcount debate??)
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Jun 1st, 2000, 06:33 AM
#34
querryperformance about 1µs!
It this is 1µs, then it's 1000 times faster than GetTickCount. Why doesn't everyone use this then?
-
Jun 1st, 2000, 06:40 AM
#35
Thread Starter
Frenzied Member
queryperformance counter is a bit harder, and the accuracy variesfrom machine to machine.
-
Jun 1st, 2000, 07:00 AM
#36
Fanatic Member
Time function (according to MS) is accurate to 1 vSecond (1/18th of a second) which is 0.05555... seconds
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Jun 1st, 2000, 07:48 AM
#37
Fanatic Member
Ok, here we go...
Code:
'Form Code
Option Explicit
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Command1_Click()
Dim Myloop As Long
Dim sTime As Double
Dim fTime As Double
sTime = GetTickCount()
For Myloop = 1 To 5000000
Call FrmSub
Next
fTime = GetTickCount
Label1.Caption = (fTime - sTime) / 1000
End Sub
Private Sub FrmSub()
Dim x As Integer
x = x + 1
End Sub
Private Sub Command2_Click()
Dim Myloop As Long
Dim sTime As Double
Dim fTime As Double
sTime = GetTickCount()
For Myloop = 1 To 5000000
Call ModSub
Next
fTime = GetTickCount
Label1.Caption = (fTime - sTime) / 1000
End Sub
'Module Code
Option Explicit
Public Sub ModSub()
Dim x As Integer
x = x + 1
End Sub
Results
Button1: 0.3, 0.31, 0.311, 0.31
Button2: 0.2, 0.21, 0.2, 0.2
Compiled version for P6, Same computer as before
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Jun 1st, 2000, 07:49 AM
#38
Fanatic Member
what happened to the code colouring in that last post ????????????????
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
-
Jun 1st, 2000, 10:32 AM
#39
transcendental analytic
HEhe, such things happens. Happened to me many times. Ok, Well i did an app a while ago that tested different methods with different arguments, and i didn't have all types but it showed the querryperformance counter have some leaks in very short intervals, according to new tests with loops
Paul while you're containing that For-loop in your counting, you get totally different results without, than without, so i'm not sure if they are reliable.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jun 1st, 2000, 10:47 AM
#40
Fanatic Member
I'm starting a new project this weekend,
Test the specs of functions, subs in same form , other form, mod etc
then test data types and arrays of them
It seems sensible to know when you're making trade-offs for maintainable / readable / modular code exactly what those trade-offs are in real terms.
Basically build a performance app for.
eg how much time do you loose for a class function?
is it slower to call a property?
I want all this in it.
If you have any ideas of things to test/compare, let me know and I try to add it.
Paul Dwyer 
Network Engineer
Aussie In Tokyo
Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|