本文整理汇总了PHP中Timer::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Timer::instance方法的具体用法?PHP Timer::instance怎么用?PHP Timer::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer::instance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInstance
public static function getInstance()
{
if (self::$instance == NULL) {
self::$instance = new Timer();
}
return self::$instance;
}
示例2: instance
/**
* Lazy loading of Timer class instance.
*
* @return Timer
*/
public static function instance()
{
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
示例3: Sharedance
<?php
require 'sharedance.class.php';
require 'timer.php';
$timer =& Timer::instance();
$timer->start('connect');
$cache = new Sharedance();
$cache->addServer(new SharedanceServer('127.0.0.1', 8989));
$cache->addServer(new SharedanceServer('127.0.0.1', 8990));
$cache->addServer(new SharedanceServer('127.0.0.1', 8991));
$timer->stop('connect');
$timer->start('run');
for ($i = 0; $i < 10000; $i++) {
if ($i % 500 == 0) {
echo '.';
}
$key = md5(microtime() . mt_rand(1, 1000));
$cache->set($key, 'Some text about the number ' . $i);
$cache->get($key);
}
$timer->stop('run');
echo "\n";
$timer->show();
示例4: __autoload
<?php
function __autoload($name)
{
require_once "classes/{$name}.php";
}
$t = Timer::instance();
$t->newTimePoint('Begin of requuest');
VehicleFactory::create(VehicleFactory::TYPE_CAR)->move();
echo '<br />';
$t->newTimePoint('After "Car" creation');
VehicleFactory::create(VehicleFactory::TYPE_PLANE)->move();
echo '<br />';
$t->newTimePoint('After "Plane" creation');
$bookAdapter = new BookAdapter(new Book('Nikolay D.', 'It woluld be nice to have my own book :]'));
echo "{$bookAdapter->getAuthorAndTitle()}<br />";
$t->newTimePoint('Prepare library.');
$booksDb = array(new Book('A 1', 'T 1'), 1, new Book('A 1', 'T 2'), 2, new Book('A 2', 'T 1'), 3, new Book('A 3', 'T 1'), 4, new Book('A 3', 'T 2'), 5);
$library = new Library('FMI Library');
for ($i = 0; $i < count($booksDb); $i += 2) {
$library->addBook($booksDb[$i], $booksDb[$i + 1]);
}
echo "Library content: total => {$library->getBooksCount()}, distinct => {$library->getDistinctBooksCount()}<br />";
$book = $booksDb[0];
$t->newTimePoint('Library - prepared, testing proxy implementation.');
echo 'Proxy test...<br />';
$proxy = new LibraryProxy($library);
if ($proxy->hasQuantityFor($book)) {
}
echo "{$book} is in the library.<br />";
$ticket = $proxy->lendBook($book);