OOPHP, fread access & Speed

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
ma1co1m
Forum Newbie
Posts: 1
Joined: Fri Dec 24, 2010 5:51 am

OOPHP, fread access & Speed

Post by ma1co1m »

I am writing a class where images are objects and one method is to replace colours in the image with an array encoded color palette in a text file. My intent is to process a directory of thousands of images (video) and so time taken by methods is key. I have noticed it only takes around .7-1 ms to retrieve this array, which to me is very quick. Before seeing this fast retrieval, I was thinking I would have to write a script outside the class to load the array for my class to then get to work and replace the colors.

Last night, falling asleep, I likened the problem to a surgeon, who has patients (images) coming into theatre and every time he needs to do a certain operation (method), he has to get an assistant to run downstairs to the store room (text file) to fetch a prosthetic/ new limb (new colour palette). Should the surgeon have a supply of new limbs at hand (array of new color palette), he would be able to process the job a lot quicker.

I would be grateful if someone could shed some light on how classes are parsed by the php engine, cos it seems that the text file has been read once and is already in memory somewhere - hence the fast retrieval speeds (to me anyway) of c. 1 ms. If this is the case, then waheeeh! Happy Xmas! And if not Happy Xmas anyway. :D


Kind Regards
Malcolm
Post Reply