Prev: VB 6 & VS?
Next: C:\WINDOWS\system32\ieframe.dll\1
From: MM on 17 Mar 2010 05:46 On Tue, 16 Mar 2010 20:46:30 -0600, "Tony Toews [MVP]" <ttoews(a)telusplanet.net> wrote: >MM <kylix_is(a)yahoo.co.uk> wrote: > >>>So close! And yet, so far. >> >>Did you find the fastest routine, Mike? >> >>Well, sure I did, Karl! >> >>How'dya do that, then, Mike? >> >>Well, gosh durn it, Karl, ya know what? I just stuck in different >>routines to call until I found one that was fastest! > >I was thinking that this entire thread summarized would be an >excellent column for Karl to write. It would never have occurred to >me that a Typelib would be that much faster then a DLL declaration. Ho, ho, ho! Even *I* now know something about typelibs since the amazing Herr Doktor Olaf helped me out with his input for multiple threading a while back in my MIDI project. Still going great guns, Olaf! I cannot break it! So, yes, Karl or anyone could write reams of stuff about how to do multithreading and other aspects of typelibs and stuff. I never understand Appleman - far too arcane for my tired old brain. I've always found that *examples* are the *best* way to learn. As long as you can suck and see, and then plug in a few ideas of your own until you break it and then you retrace your steps a bit before trying something else, then most things become easier to understand (not nuclear power stations through this "trial-and-error" approach, naturally enough...) MM
From: MM on 17 Mar 2010 05:48 On Tue, 16 Mar 2010 20:38:03 -0600, "Tony Toews [MVP]" <ttoews(a)telusplanet.net> wrote: > >"Mike Williams" <Mike(a)WhiskyAndCoke.com> wrote: > >>0.056 microseconds for Nobody's VB method > >I sure wish nobody would change their name to somebody. <smile> Yeah, but somebody would be just as anonymous. A new moniker entirely, perhaps? How about "Monica", Nobody? Somebody? Anybody? MM
From: Schmidt on 17 Mar 2010 07:38 "Tony Toews [MVP]" <ttoews(a)telusplanet.net> schrieb im Newsbeitrag news:mig0q55u81fsesp4b8632n6lpijj3jlorl(a)4ax.com... > I was thinking that this entire thread summarized > would be an excellent column for Karl to write. > It would never have occurred to me that a Typelib > would be that much faster then a DLL declaration. Speaking of Calling-Overhead, maybe something that worth' mentioning too. Even in calling VBs "plain, ownerdefined Functions" are larger differences, depending on *where* you place them (Form-, Class- or *.bas-Modules) and how you attribute them (Private, Friend, Public). One can measure that easily (Mike?... ;-)) by placing just a simple "Long-Reflection-Function" in different Modules (changing some Attributes where they apply). In short, something like that: Public Function ReflectLong(Byval LngParam) As Long ReflectLong = LngParam End Function has the least calling-overhead, when placed within a *.bas module. In my tests it was between 6-8 times faster, compared with placing the Function in a Form Publically - yet faster by factor 3-4, when this Form-Function was attributed with Private in the Form-Module. All measurments taken "fully native compiled" (all options checked). The higher differences come mainly from "OLE-hResult- based rewriting" of the Function-Declares under the hood by the compiler (in case they are in Classes or Forms). I used a simple Test-loop like that: Dim T As Single, i As Long, LngResult As Long T = Timer For i = 1 to 10000000 LngResult = i 'just to measure loop-overhead without any calls 'LngResult = ReflectLong(i) 'just place the Function in different modules Next i Caption = Timer - T @Jim: maybe that explains the larger differences, when comparing with SwapEndian08 - (some time ago and now) - since it highly depends, where SwapEndian08 is placed and attributed. Olaf
From: Mike Williams on 17 Mar 2010 08:25 "Schmidt" <sss(a)online.de> wrote in message news:%230vi2ZcxKHA.3408(a)TK2MSFTNGP06.phx.gbl... > Speaking of Calling-Overhead, maybe something > that worth' mentioning too. Even in calling VBs > "plain, ownerdefined Functions" are larger differences, > depending on *where* you place them (Form-, > Class- or *.bas-Modules) and how you attribute them > (Private, Friend, Public). > One can measure that easily (Mike?... ;-)) by placing > just a simple "Long-Reflection-Function" in different > Modules (changing some Attributes where they apply). > In short, something like that: > Public Function ReflectLong(Byval LngParam) As Long > ReflectLong = LngParam > End Function There's that Variant again, Olaf ;-) Actually I would imagine that's just a "typo" and that you have probably used a Long in your real test code. I get the following at this end (when using Byval LngParam as Long), for the three specific tests I've conducted on my Celeron laptop: 05 nanoseconds (Public in Module) 08 nanoseconds (Private in Form) 51 nanoseconds (Public in Form) Mike
From: Schmidt on 17 Mar 2010 08:52
"Mike Williams" <Mike(a)WhiskyAndCoke.com> schrieb im Newsbeitrag news:OqKQqzcxKHA.4492(a)TK2MSFTNGP05.phx.gbl... > > Public Function ReflectLong(Byval LngParam) As Long > > ReflectLong = LngParam > > End Function > > There's that Variant again, Olaf ;-) Arrgh, good catch, thank you... > Actually I would imagine that's just a "typo" and that > you have probably used a Long in your real test code. Of course. > I get the following at this end (when using Byval LngParam > as Long), for the three specific tests I've conducted > on my Celeron laptop: > > 05 nanoseconds (Public in Module) > 08 nanoseconds (Private in Form) > 51 nanoseconds (Public in Form) Thanks for testing - and although the differences between 'Public in Module' and 'Private in Form' are somewhat larger here - this is basically matching with my results. (maybe substract the calling-overhead of the "pure loop, using only the direct asignment: LngResult = i" from all the timing-results too). So, as a "general rule" for high-frequently called "primitive Helper-Functions which do only some short calcluations" - it's worth it, to place them in Modules. But of course all that becomes "more academical", if inside these Functions happens something more than "just a few lines of math-ops on Longs"... or if the Param-Count gets higher, etc. Olaf |