Posts

Showing posts with the label fopen

Resource Performance

You ever run your application and realize it's taking a long time to process? It would probably be a good idea to take a look at your application and see how many times you open and close a resource or a stream. If you have a lot of functions that open a stream, query it, and then close the stream, then it's likely that might be the bottleneck of the application. In order to reduce the amount of time it takes to process the application, it's usually best to open the steams to the resources needed when the application starts, and then close them when the application ends. Here's an example class that deals with files: class FileHandler { /** * Implements the singleton pattern. * @var FileHandler */ protected static $_instance; /** * Holds the current file pointer. * @var [resource] File pointer */ protected $_fp; /** * Starts up the resource handler. * @param filename string The path to a file to open. ...