[eluser]Xeoncross[/eluser]
I am a big performance buff - I love to squeeze everything I can out of my code. But at the same time it is just stupid do something the wrong way just to get a tiny-tiny bit of extra speed. ($time = 60 * 60 * 24 vs $time = 86400).
So now that you know where I am coming from - I want to pick your brains on the whole array vs object results thing (and I have some data).
I ran some benchmarks on object/array creation and storage and came up with some numbers. Please not that this is NOT a benchmark from the CI functions result() and result_array() as too many other factors would affect a benchmark of this size. Instead I just use plain array() and stdClass() to create the results.
Code:
//Numbers
//100,000 numbers from 0 to 100,000
ARRAY : 7543.4 kbytes Used
0.074545 Time
OBJECT: 8184.6 kbytes Used
0.162911 Time
//Strings
//10,000 [a-z] values from 5 - 40 chars long (same array used for both)
ARRAY : 491.7 kbytes Used
0.006808 Time
OBJECT: 491.6 kbytes Used
0.013479 Time
As you can see only with large result sets would the 2x gain that arrays have over objects become important. So with this known, is there some reason arrays might be evil when used as result sets - after all it isn't like OOP applies as the result isn't going to be extended or set as a object to be inherited.
I used to use arrays - then I moved to PDO (and later CI) and loved the object results - but now I am questioning it.
Any thoughts? (Other than "it's too small to mater"...)