Download the PHP package imkingdavid/load-timer without Composer
On this page you can find all versions of the php package imkingdavid/load-timer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package load-timer
LoadTimer Class
A simple PHP load time measuring class. This class intends to follow the PHP FIG Standards, so if you notice anything that is wrong, let me know and/or submit a Pull Request to fix it (see below).
Copyright (c) 2012 - David King ([email protected])
Requirements
PHP 5.4
License
This may be used as needed for any purpose, free or commercial with no restriction. This product is provided as is with no warranty.
Contributing
If you have something to add or you see something broken, please feel free to create a ticket and/or a Pull Request. I do not have any specific guidelines for commit messages, other than that they are brief and explain exactly what is changed.
Installation & Usage
This repository is a Composer-enabled package. For information about installing and using Composer, check out http://getcomposer.org.
Place the following code at the start of your page.
Tip: The class does NOT automatically begin timing unless the constructor's first argument is set to true like so:
If you choose not to make the timer auto-start, you will need to start it yourself. Go to the point in your file at which you wish to begin timing, and add the following line:
Tip:
$timer->start()
overwrites the time at which the timer started. You can use this to your advantage, if you wish to have it begin at a different point in a script if a certain condition is met.
If you want to mark notable points in the code without ending the timer
altogether, you can use the $timer->lap()
method. It takes a single argument
which is a string message that simply describes the lap. It defaults to:
Lap #
where # is the number of laps before the current one, plus one.
Later, you can access all of your laps using the $timer->laps()
method. It
returns an array like so:
Finally, when you want the timer to end, place the final line of code.
Note that by default, the end() method returns the load time. You can have it echo a string as well by setting the first argument of end() to true. You can modify the default string that is printed by setting the second argument of end() to a string that contains %f (sprintf() is run when the string is printed).