logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Use of SQLFetch() and TMI Errors
Goto page Previous  1, 2
 
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
dguntner



Joined: 31 Dec 2004
Posts: 116

PostPosted: Wed Aug 24, 2005 6:33    Post subject: Reply with quote

You're probably right, Prim. And yea, that's the solution I use on my server so that I can store needed information about a departing player in the database. Works well. Smile

--Dave
Back to top
View user's profile Send private message
Lanthar D'Alton



Joined: 10 Feb 2005
Posts: 100

PostPosted: Thu Sep 08, 2005 1:41    Post subject: A thread you should probably read Reply with quote

http://www.nwnx.org/phpBB2/viewtopic.php?t=155&postdays=0&postorder=asc&start=0

That discusses the discovery that nwscript switch statements are equivalent to giant if/else statements.

of particular relevance to this thread:

Lanthar D'Alton wrote:
Here are a few more things about efficiency for those not so keyed to it...

two scripts:

strcompare
Code:

 void main()
 {
     int i=0;
     for(i=0; i<8191; i++)
         check(i);
     SendMessageToPC(GetLastUsedBy(), "strcompare done");
 }
 
 void check(int variable)
 {
     if("123"=="abc")
         1;
 }


The code I used for ints (main was same as above):
intcompare
Code:

 void check(int variable)
 {
     if(1==variable)
         1;
 }


That strcompare one will run precisely 1 too many commands for nwn... causing a TMI error, AND sending the message anyway... oddly the intcompare one also TMIs but never sent the message. Both scripts do complete if I change the for(...) to only go to 8190.

Anyway, that's just something I always wondered... how many instructions are too many. I'm not surprised that it comes rather close to a power of 2 in the loop (8192)...Smile

As for the importance of running this test... well, it gave me efficiency results that are very good to demonstrate why using ints is better than using FindSubString or any of that.
Code:

intcompare : 0.007793 per call
strcompare : 0.037566 per call


So... Comparing 3 letters to 3 other letters eats ... 4.82 times the cpu as comparing 2 integers.

Anyway, that's just a bit of example to explain why we programmers don't like to run string comparisons unless we absolutely have to.

-Lanthar


Thus, it can make that script run 8190 times through it's loop without dying.

Naturally there's some overhead to the function call and some other stuff.
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
dguntner



Joined: 31 Dec 2004
Posts: 116

PostPosted: Fri Sep 09, 2005 4:03    Post subject: Reply with quote

I remember that discussion. I also remember posing the question asking if you had tried compiling the module with the PRC stand-alond script compiler to see if it treated switch statements differently than the default Bioware compiler.

Never did get an answer from you on that. Very Happy

--Dave
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> General Discussion All times are GMT + 2 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group