Found my slowdown. FYI.

DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #16
The real problem with -sortedArrayUsingSelector: is not the algorithm, but that you have an objc-message-send for every comparison. I've written a sorter, in objc, that computes a floating point value for every object once, and compares those for sorting. It uses a primitive merge sort, but it's at least an order of magnitude faster than -sortedArrayUsingSelector:. It is one message send for each object, instead of one for each compare.
Quote this message in a reply
Member
Posts: 110
Joined: 2009.07
Post: #17
arekkusu Wrote:Pah. Real coders emulate 6502 in geometry shaders Wink

Touche. LOL

That's a bit beyond me at the mo'.
Quote this message in a reply
Member
Posts: 110
Joined: 2009.07
Post: #18
DoG Wrote:The real problem with -sortedArrayUsingSelector: is not the algorithm, but that you have an objc-message-send for every comparison. I've written a sorter, in objc, that computes a floating point value for every object once, and compares those for sorting. It uses a primitive merge sort, but it's at least an order of magnitude faster than -sortedArrayUsingSelector:. It is one message send for each object, instead of one for each compare.

Good point - I don't know how I missed that. Oh, yes I do. Incompetence. Blush

Out of interest:

I was using the selector to sort by texture ID. I presume everyone else uses it on Zs instead of depth-testing. Or are you ordering by other GL states?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Symbol(s) not found using oalTouch example code monteboyd 2 3,285 Sep 26, 2010 10:49 PM
Last Post: monteboyd
  Slowdown while playing many OpenAL sounds and accessing AVAudioPlayer.playing Rasterman 6 5,386 Aug 31, 2010 09:46 PM
Last Post: headkaze
  Texture2D class Found Gillissie 1 3,089 Mar 16, 2009 03:49 PM
Last Post: jeonghyunhan
  error: framework not found ApplicationServices kancho 1 3,588 Nov 23, 2008 11:33 PM
Last Post: OneSadCookie