Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
dnepr
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Any optimization tips

p[op+o+z]=p[op+o];
p[op+o]=((b-EMPTY)!=0?b:0);
You also seem to be doing stuff like calculating op+o twice. Use a local variable and only do a single addition vs. doing it twice. Check the code for other places that do this.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Any optimization tips

Can you think of any way to get rid of getValue? I was able to cut 300 milliseconds out by removing all the other function calls (used to be about 8). The function calls were all to convert to and from the pixel format (the 'q' variable).

 

The code was written for 8bits per pixel, format is RRRGGGBB. If you don't know how to convert to and from:

component = (decimalValueOfpackedComponent / ((2^numberOfBitsForPackedComponent)-1)) * 255

 

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Any optimization tips

[ Edited ]

I will work on the loop (until I can remove it), and should've tried harder to remove duplicate math equations.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
dnepr
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Any optimization tips

I think if you store q[] and c[] as a IntIntHashtable... you will get a faster access.

 

It is native and very fast.   Try it out.

Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Any optimization tips

Tried it out, reaked havok on the way the graphics are drawn. Function calls slowed it down too.

 

Statistics as of right now: Full screen graphics drawing: 2 milliseconds, Process: 189 milli... wait a second. What happened? The time variable is returning 1089 milliseconds!! How did it get over a second again?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
dnepr
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Any optimization tips

[ Edited ]

You're testing on a real device?

 

 

Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Any optimization tips

Do you think 4 if statements would be better then a loop? What about a large switch statement?

 

Can you think of anything way that:

((r*=5)%(getValue(pOpo-b)/5+2)>5)

Can be optimized?

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Any optimization tips

No, give me a few minutes and I can get you real device stats.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
rcmaniac25
Posts: 1,804
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.2174, Z10 (STL100-3)-10.3.0.700 Dev OS, Z30 (STA100-5)-10.3.0.700 Dev OS, PlayBook (16GB)-2.1.0.1917
My Carrier: Verizon

Re: Any optimization tips

Scratch that, after 2 hours of trying I still can't get Eclipse to connect to my Storm2. If I disconnect the USB cable then Eclipse fails (obviously) and my BlackBerry finishes connecting, then exists debug mode.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Please use plain text.
Developer
dnepr
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: Any optimization tips

 


rcmaniac25 wrote:

Do you think 4 if statements would be better then a loop? What about a large switch statement?

 

Can you think of anything way that:

((r*=5)%(getValue(pOpo-b)/5+2)>5)

Can be optimized?


 

It's hard to tell. You really have to measure each  expression by themselves.

 

It'll probably be faster inlining four boolean expressions i.e.:   bool ? 0 : (bool2 : ? 0 :bool3) etc.    Try to figure out which occurs most and place those in beginning of the expression.

 

 

If you're getting 100-300ms on simulator... the real device will be much slower than that.

Please use plain text.