-
Notifications
You must be signed in to change notification settings - Fork 5
util timed task
Harmen Janssen edited this page Jan 19, 2015
·
3 revisions
Want to report on the time taken to perform a task? Wrap Garp_Util_TimedTask
around it!
$timedTask = new Garp_Util_TimedTask(array($this, 'importEverything'), $arguments);
$functionResponse = $timedTask->perform();
echo 'Thanks for waiting ' . $timedTask->getTime() . ' seconds.';
Particularly useful for reporting back on the CLI.
You can format the time like this:
echo 'It took ' . $timedTask->getTime(Garp_Util_TimedTask::FORMAT_MINUTES) . ' minutes.';
echo 'It took ' . $timedTask->getTime(Garp_Util_TimedTask::FORMAT_HOURS) . ' hours.';
Note that TimedTask
accepts anything you could normally pass to call_user_func_array()
.