Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Original thread:
Post 36 made on Tuesday April 27, 2010 at 20:26
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,007
On April 27, 2010 at 18:31, sWORDs said...
Lyndel, when Philips (Koen B) checked my sources they commented that it would improve performance when all sub functions would be moved out of onData and would sit on their own. Not sure if it helps you, but maybe it's usefull.

Do you have a simple example of something they commented on so we are both on the same page?

I try to never use local functions (useful for closures) in an onData() call. I'm hoping you are not referring to calling other functions, just defining local ones.

However, I will double check some code I'm optimizing to see if I find something.


Other ways that I'm improving my modules is by testing loops with if then else and case. (Generally speaking case is faster, but when nesting case it often is faster to switch one to if else if) 

Can I get an example here please? I think I understand but a picture is worth 1000 words.

And less lines of codes is generaly better, but sometimes it helps to not put everything in sub functions but copy them in.
Someways of coding also seem to be running a bit faster:
this.SendKey = {
key_return:function(){self.Command("Sendkey(1)");},
key_enter:function(){self.Command("Sendkey(2)");},
};
[...]

is faster then:
this.SendKey = {};
this.SendKey.key_return = function(){self.Command("Sendkey(1)");};
this.SendKey.key_enter = function(){self.Command("Sendkey(2)");};
[...]

Obviously, that would be the case. I try to do this as well. Note that if you are putting functions into objects over and over again, it makes sense to define a class or a single function.


function SendKey(){}
SendKey.prototype.key_return = function(){self.Command("Sendkey(1)");};
SendKey.prototype.key_enter = function(){self.Command("Sendkey(2)");};

OR

// These 2 functions defined at one time either in Page or Activity script.
function key_return (){self.Command("Sendkey(1)");};
function key_enter(){self.Command("Sendkey(2)");};
this.SendKey = {key_return:key_return,key_enter:keyEnter};


Not using (or as little as possible) constructor functions (those that you call with new) speeds things up really well. I only use them on page load except for new Image and a few others which I can't do without.

Yes, that woudl be the case, Each time you call a function with 'new', it means an additional object which adds to Garbage Collection overhead.

Also do not use GUI.updateScreen or System.delay.

Both of these are a definite no-no for any event-driven programmer.
And if you think TCP/IP with Denon is trouble, try to do the same with RS232, after that you'll feel a lot better. :)

LMAO. That is why I switched to TCP/IP, especially since the 232 via RFX9600 is not true full-duplex. A write to Serial port clears whatever data is currently in receive buffer which makes you have to wait for full response prior to sending next command. Also note that Ports 3 & 4 on RFX9600 share the same UART so doing 2-way on either of those ports will be problematic based on the lack of full-duplex. (A send on port 4 could kill data in buffer that your code is waiting to receive on port 3).

Data corruption example using Denon Channel Volume Query:

CV?
You must hold off next command until you get response line for last channel. ie. Before sending MS?.
Lyndel McGee
Philips Pronto Addict/Beta Tester


Hosting Services by ipHouse