From: MM on
On Sun, 14 Mar 2010 08:57:59 -0400, "Jim Mack" <jmack(a)mdxi.nospam.com>
wrote:

>MM wrote:
>>
>> So I do not understand where you're coming from when you state that
>> "it all runs orders of magnitude faster", since the comparisons are
>> very similar, i.e. Shifts, Swaps, and Bendians were all practically
>> identical before (17), and they still are (10), after repositioning
>> the n = "&H"... bit.
>
>If that's the way you'll actually use the function in code, then the
>comparison is valid for your purpose. It points up what smart
>programmers have said forever: optimize only in conjunction with a
>profiler. Fine tuning something that sits in the middle of a slow or
>rarely-used function is wasted effort.

But if one establishes which 'something' is faster, which we now have
done (choose any of SwapEndian08, Bendian or Shift - all are faster
than my original functions), then that would likely be the standard to
use in other projects. Although I might not be calling an Endian
routine very often in the MIDI app, I might well want to do so in
other apps.

Thanks to all who provided tips and links!

MM
From: MM on
On Sun, 14 Mar 2010 09:02:21 -0500, "Nobody" <nobody(a)nobody.com>
wrote:

>"MM" <kylix_is(a)yahoo.co.uk> wrote in message
>news:4vbpp5tpjnqh06i0befva6tstdvc4p8n6s(a)4ax.com...
>> In each case I entered the string 4B3B2B1B into txtNumber. The same
>> calling routine was used in all cases:
>>
>> Dim start As Date
>> Dim n As Long
>> Dim count As Long
>> start = Now
>> For count = 1 To 1000000
>> n = "&H" & txtNumber
>> txtResult = Hex$(Endian32_UsingCopyMem(n)) ' This line changes
>> as per method used - see below
>> Next
>> MsgBox "CopyMem: " & DateDiff("s", start, Now)
>>
>> 1. txtResult = Hex$(Endian32_UsingCopyMem(n))
>> 2. txtResult = Hex$(Endian32_UsingShift(n))
>> 3. txtResult = Hex$(SwapEndian08(n))
>> 4. txtResult = Hex$(Endian32_UsingBendian(n))
>> 5. txtResult = Hex$(Endian32_UsingString(n))
>
>Besides what Mike suggested, you need to move txtResult = Hex$() outside the
>loop because you are also measuring the conversion to a Hex string in the
>loop. Try saving the result into a Long variable, then convert the string
>after the MsgBox.
>
>Also, use Timer function because it has a resolution of about 10 to 20 ms,
>so timing code would be:

[snipped]

This was not about absolute speeds, but about establishing which
routine/method is faster, relative to others, which we have now done.
For instance, the txtResult = Hex$() assignment is the same in all
cases, therefore the overhead will be identical in all cases. I didn't
seek to get an accurate time down to milliseconds (else I might have
used GetTickCount), but simply to get a measure of the time *in
comparison* with other methods. Whether a routine takes 10 'thingies'
or 20 'thingies', it's obvious that the '10' example is faster,
irrespective of how long a 'thingy' itself is.

MM
From: Mike Williams on
"MM" <kylix_is(a)yahoo.co.uk> wrote in message
news:t6kpp5h97ngfbsk8m6rl8i488e9d4v6n4v(a)4ax.com...

> I've just repositioned n = "&H" & txtNumber outside the loop.
> Timings are:
> 1. CopyMem 13 13 13 [seconds]
> 2. Shifts 10 10 11 [seconds] . . etc
> So I do not understand where you're coming from when you
> state that "it all runs orders of magnitude faster"

When I said that you should move the "n = "&H" & Text1" out of the loop on
the grounds that it was very slow by comparison and that it was "swamping"
your timing of the various actual endian flip functions I hadn't noticed
that you also had another extremely slow statement in the same loop, the
txtResult = Hex$(Endian32 . . etc statement. There were at least two flies
in the coffe and I had initially noticed just one of them when I decided the
coffee was not for me, and I had thrown it away without noticing the other
fly ;-)

If you remove the other fly as well then you will be able to drink the
coffee, and you will in that case definitely see that "it runs orders of
magnitude faster". It's up to you of course if you want to compare the
weight of the peas by placing them in builder's skips and weighing the
skips, but personally I would weight just the peas themselves if I were
doing it myself ;-)

Mike



From: Mike Williams on
"MM" <kylix_is(a)yahoo.co.uk> wrote in message
news:4vbpp5tpjnqh06i0befva6tstdvc4p8n6s(a)4ax.com...

> Here are my final results, done just now with
> the COMPILED app (compiled to native code
> optimise for fast code . .

By the way, MM, I've just re-read some of my posts in this thread and in
many cases it does look as though I have responded in a quite aggressive
manner. I did in fact sometimes go a little bit "over the top", but that was
simply because I have always had this "thing" about isolating everything
else from the timing routines when I am writing code specifically to test or
compare the speed of various functions or methods. I did not, however,
intend to come across in quite the way it looks and I certainly did not ever
intend to appear agressive, and I apologise if I did actually come across
that way.

Mike


From: MM on
On Mon, 15 Mar 2010 11:21:20 -0000, "Mike Williams"
<Mike(a)WhiskyAndCoke.com> wrote:

>"MM" <kylix_is(a)yahoo.co.uk> wrote in message
>news:4vbpp5tpjnqh06i0befva6tstdvc4p8n6s(a)4ax.com...
>
>> Here are my final results, done just now with
>> the COMPILED app (compiled to native code
>> optimise for fast code . .
>
>By the way, MM, I've just re-read some of my posts in this thread and in
>many cases it does look as though I have responded in a quite aggressive
>manner. I did in fact sometimes go a little bit "over the top", but that was
>simply because I have always had this "thing" about isolating everything
>else from the timing routines when I am writing code specifically to test or
>compare the speed of various functions or methods. I did not, however,
>intend to come across in quite the way it looks and I certainly did not ever
>intend to appear agressive, and I apologise if I did actually come across
>that way.

No worries! My 63�-years-old skin is fairly thick by now - although I
did not perceive any undue harshness from you or anybody else. Usually
Karl and I like a bit of a ding-dong, but I always like to indulge the
younger guy...

Going back to endianness for a brief (promise!) moment, we people who
program computers are often rather fixated on details, which is a good
thing. We are probably the one group which is always in danger of
running out of high horses, and I am no saint when it comes to that.
In a different life, I'd have liked nothing to do with computers and
to have been an Errol Flynn character who gets the girl, lives on the
edge and ends up dead, Bonnie and Clyde style, in a shoot-out with the
cops. But we just have to accept the hand we've been dealt, so it's
back to the gardening for me this afternoon.

MM
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Prev: VB 6 & VS?
Next: C:\WINDOWS\system32\ieframe.dll\1