if this has been done, my apologies. i was bored, and the only content that’s ever here are questions.. boorriinnngg
It occured to me that it was a little ridiculous to have a certain function call all over my app whos sole purpose was to return a string. How silly. The culprit? base_url(). errr. I did a little comparision to see for myself just how much this greedy little bastard was stealing from me.
base_url() vs APP_PATH (as old school constant)
my test - elapsed time of 10,000 iterations through a for loop, 10 seperate executions, then averaged.
base_url()—————-APP_PATH
.1194—————————.0056
.1311—————————.0051
.1200—————————.0097
.1264—————————.0067
.1272—————————.0309
.1306—————————.0214
.1273—————————.0052
.1568—————————.0276
.1262—————————.0064
.1273—————————.0294
avg speed
- base_url() > .1292
- APP_PATH > .0148
APP_PATH faster by 8.7X
It was even worse for concatenations. A typical operation for any CI dev is to concat base_url() with the rest of the desired url. I’m to lazy to make another cheesy graph but APP_PATH was faster through 10,000 iterations by 12.8X
Moral of the story.. don’t be a pig! use static method calls and constants where appropriate.
