ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
Very Puzzling Function (Sdk)
Very Puzzling Function // SdksilencedJun 5, 2002, 9:12am
How so? And another thing, his is all just opinions as well ;).. excluding
the fact about doing it before pueberty which has no basis for expertise. Especially if it's in a language he knows very little. Again, that's an opinion too. --Bowen-- Have $3... want a website? http://www.smartpenguin.com/affiliate.php?id=12 [View Quote] grimbleJun 5, 2002, 9:51am
How so???? Apologies to Brant for keep referring to the code he posted, but
.... "One thing I can suggest is that you use > instead of >= since I don't know if VB figures that out for itself and I suspect it does not." ** This may be true ... I read this as using ((x < y) or (x = y)) in place of (x <= y). I don't know, but datedman certainly wasn't suggesting changing the code so it didn't fit the logic. If this did perform better, the optimizer in the native code compiler would almost certainly pick it up. "Another thing I see happening is that you're comparing to awobj.x several times and it's possible that VB will be faster if you assign this to a variable." ** Correct ... BIGTIME "Also, you could put more parentheses in some expressions to make things more clear to VB for instance in" ** Again, whether adding parentheses is something that will improve performance I don't know, but it would make sense if it did, by explicity defining the expression and the order in which they are to be evaulated. Probably only a small scale and in native code, the order would be described by the optimizer. It may well help the performance of P-Code compiles though. "You also have several places where you're subtracting tempx from awobj.x, assign to a variable." ** Correct - obviously inefficient "either I am missing something drastic or "Xcounter" and "Zcounter" are never used within the loops." ** Correct - they're not "why thehell would you set up step loops using xcounter and zcounter and then never reference them within the loops?" ** Correct - perfectly valid point that meant a mass of pointless code execution as it was posted How "right" do you need him to be before you stop judging? These aren't opinions ... they're mostly facts, and not exactly obscure ones at that. The vast majority of programming isn't about syntax and therefore its not about language knowledge. You don't have to start totally clueless when you learn a new language because the basic contructs and methods are the same. Datedman doesn't need VB experience to make suggestions, in fact some of what he suggested actually has a much bigger impact in VB than he may have realised when he posted. KAH's reply was cocky, bordering on condescending and rude (in my opinion). Some of what he said was wrong and other parts were just opinions of his own. I think he deserved a slap, and he got (a gentle) one. Now stop looking for a fight and add something helpful. Grimble [View Quote] datedmanJun 5, 2002, 2:24pm
Hehe yah I had almost forgotten how any post here, no matter how helpful, is
just fodder for folks to jump in and snipe. As far as the < instead of <=, I thought this to be obvious but I suppose not. I'm assuming these are long ints. If they are, then let's say the loop is a valid one and we're using the loop control variable within the loop--instead of: for xtest = 1 to 100 if x <= xtest I'd just make it something like: for xtest = 2 to 101 if x < xtest ....and as far as my seniority...I went to a school in a time when CPU was much more expensive than programmer time. And it was a good school IMO, Miami-Dade Community College. Actually when I went there it was just because it was cheap, and they had big computers and it was too expensive to have a decent one yourself--but it turned out that the teachers and curriculum there were very good. Later I went to a four-year school briefly but (at least at the time, and at this school) I found that they were not focussed on teaching practical stuff, mostly theory/math instead. So we nit-picked optimization of Assembler and COBOL code and such. When we talked about something being "expensive" we meant it ate CPU time. Now "expensive" might mean that it takes more customer support. :) Hell we didn't even HAVE customer support in those days, and we liked it! Heehee, man nobody had a computer on their desktop. What a different world that was. After school, same thing really--I learned to write fast code that was also readable/maintainable. We didn't have Java, or VB, or C++ for that matter. And we were programming for machines that are a joke now, and OS's that were also quite primitive. So there was less to learn in many ways; consequently we focussed on things that many programmers nowadays never learn. Anyway, I assure you that my post was meant to be nothing but helpful. I didn't mean to belittle the code or anything like that, just to point out some things that might help it run faster. I assume that when people snipe at me, they think my post was a snipe in the first place and are contesting that. But I am basically just not oriented for anything but providing help. That's how my mama raised me. :) DM [View Quote] > How so???? Apologies to Brant for keep referring to the code he posted, but > ... > <snippety snip> > kahJun 5, 2002, 2:29pm
"datedman" <russell at synergycorp.com> wrote in
news:3CFD7ED2.7FFF5DDD at synergycorp.com: > As I say, I know very little about VB. :) > > However, read my message again and THINK before you reply. All my > points are actually valid to some extent, or may be. :) I'd hazard a > guess that I was optimizing code before you reached puberty. This is > not a put-down, just a simple statement of the fact that I've been > doing this a loooong time and I am actually quite good at it. I know you had a very good point about those For loops, I was just trying to explain why Brant had done it, I would probably have used a Do loop myself. You might've optimized code for a while, but it doesn't really matter, does it? :-)) Anyway, I have no problems with your post, it had quite a few valid points, even though I don't see the interest in gaining a few milliseconds in such an app lol, but I guess it's like me and valid HTML, it doesn't make any difference really to not have quotes, etc, but it still should conform with HTML standards, we all need our little quircks ;-)) KAH grimbleJun 5, 2002, 3:19pm
No KAH, you're missing the point mate. Its not abotu which method to use to
do that loop, its the effect of the loop of the execution. If nothing changes between between each pass of the loop, then the loop is redundant. Consider the following loop, which is a simplified equivalent to what is in the posted code: y = 1 matched = False For x = 1 To 100 If y = 20 Then matched = True Exit For End If Next x This loop (whether implemented as a For ... Next or a Do ... Loop) will ALWAYS, without fail, execute 100 times and "matched" will ALWAYS end up as False because in each pass of the loop, y = 1. The only thing that is changing between each pass is the value of x which is not referenced within the loop. The same is true of the original code, where the only values that change in the loop are XCounter and ZCounter which are not referenced so every condition within the loop will evaluate to the same as it does in every other pass. To be more specific, the value of (AWObj.X >= CellX), (AWObj.X <= CellX), (AWObj.Z >= CellZ) and (AWObj.Z <= CellZ) do not change. If theconditions fail on the first pass, they will fail on every pass. If you still don't get it, then I guess you never will. [View Quote] datedmanJun 5, 2002, 4:50pm
I just like to optimize. :)
[View Quote] > "datedman" <russell at synergycorp.com> wrote in > news:3CFD7ED2.7FFF5DDD at synergycorp.com: > > > I know you had a very good point about those For loops, I was just trying > to explain why Brant had done it, I would probably have used a Do loop > myself. You might've optimized code for a while, but it doesn't really > matter, does it? :-)) Anyway, I have no problems with your post, it had > quite a few valid points, even though I don't see the interest in gaining > a few milliseconds in such an app lol, but I guess it's like me and valid > HTML, it doesn't make any difference really to not have quotes, etc, but > it still should conform with HTML standards, we all need our little > quircks ;-)) > > KAH chazradJun 5, 2002, 7:01pm
second this
"datedman" <russell at synergycorp.com> wrote in news:3CFE3714.E94A255F at synergycorp.com: > Hehe yah I had almost forgotten how any post here, no matter how > helpful, is just fodder for folks to jump in and snipe. > kahJun 7, 2002, 1:05pm
"chazrad" <petrossadeletethis at msn.com> wrote in news:3cfe7c14
at server1.Activeworlds.com: > second this But who's sniping who? I guess datedman meant I was "sniping" him, but that's a misunderstanding, I was absolutely not trying to be rude or put down datedman! If anybody was "sniping" someone in this thread, it was Grimble who "sniped" me! Sometimes I wonder why I bother to read and post to these NGs... KAH datedmanJun 8, 2002, 11:46am
Cool, sorry my misunderstanding.
[View Quote] > "chazrad" <petrossadeletethis at msn.com> wrote in news:3cfe7c14 > at server1.Activeworlds.com: > > > But who's sniping who? I guess datedman meant I was "sniping" him, but > that's a misunderstanding, I was absolutely not trying to be rude or put > down datedman! If anybody was "sniping" someone in this thread, it was > Grimble who "sniped" me! Sometimes I wonder why I bother to read and post > to these NGs... > > KAH |