Re: copymemory basic question
- From: mscir <mscir@xxxxxxxxx>
- Date: Thu, 01 Sep 2005 17:42:01 -0700
Karl E. Peterson wrote:
Donald Lessau wrote:
"Karl E. Peterson" <karl@xxxxxxxx> schrieb im Newsbeitrag...
Public Sub SwapStr05(s1 As String, s2 As String) Static lpTmp As Long ' Use PutMem4 and GetMem4 directly from runtime. ' This method requires no typelibs! lpTmp = StrPtr(s1) 'Call GetMem4(VarPtr(s1), lpTmp) Call PutMem4(VarPtr(s1), StrPtr(s2)) Call PutMem4(VarPtr(s2), lpTmp) End Sub
Yeah, sweet!:-)
Of course, I could not resist to test it against a non-Static version, and again, non-Static came out clearly faster here (VB5, EXE, all opt). As opposed to your results, weird.
I really don't understand that... They are so nearly consistent here. Almost identical, but with an edge on Static. Sometimes they flip back and forth. Has to be termed insignificant difference here.
SwapString/Call 1: "a", "b" VB5-COMPILED/AllCompileOpt ON: 10 x 100000 iterations, 01.09.2005 09:58:00 System: Athlon XP 2000+, 512 RAM, Win XP Pro SP1, IE6.0
What VB? I was using VB5/SP3.
Other differences are processor (dual-2.4 Xeons here) and OS (W2K/SP4).
That's a real difference. Dang. Wish I understood the variation.Rank - Rel.Time - Abs.Time - Routine - Description 3 - 1.64 - 0.082µs - SwapString09 - 1 - 1.00 - 0.050µs - SwapString10 - 2 - 1.35 - 0.068µs - SwapString11 - Static
SwapString09 = my previously posted CopyMemory version. SwapString10 = your SwapStr05, but non-Static SwapString10 = your SwapStr05, Static (as quoted above)
Thanks... Karl
Have you seen this:
http://www.aivosto.com/vbtips/not-optimize.html
Static makes your app sooo static
Did you know that Static local variables are slower than the normal Dim locals? One could think that Statics are faster as they don't need to get allocated every time you call the procedure. But it's not so. Use Dim unless you have to do Static.
Mike .
- Follow-Ups:
- Re: copymemory basic question
- From: Sam Hobbs
- Re: copymemory basic question
- From: Karl E. Peterson
- Re: copymemory basic question
- References:
- Re: copymemory basic question
- From: Karl E. Peterson
- Re: copymemory basic question
- From: Donald Lessau
- Re: copymemory basic question
- From: Jim Mack
- Re: copymemory basic question
- From: Donald Lessau
- Re: copymemory basic question
- From: Karl E. Peterson
- Re: copymemory basic question
- From: Jim Mack
- Re: copymemory basic question
- From: Karl E. Peterson
- Re: copymemory basic question
- From: Jim Mack
- Re: copymemory basic question
- From: Karl E. Peterson
- Re: copymemory basic question
- From: Donald Lessau
- Re: copymemory basic question
- From: Karl E. Peterson
- Re: copymemory basic question
- Prev by Date: Re: copymemory basic question
- Next by Date: Re: copymemory basic question
- Previous by thread: Re: copymemory basic question
- Next by thread: Re: copymemory basic question
- Index(es):
Relevant Pages
|
Loading