当前位置: 首页>>代码示例>>PHP>>正文


PHP Timer::instance方法代码示例

本文整理汇总了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;
 }
开发者ID:rverbrugge,项目名称:dif,代码行数:7,代码来源:Timer.php

示例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;
 }
开发者ID:ndobromirov,项目名称:php_course_2012,代码行数:12,代码来源:Timer.php

示例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();
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:23,代码来源:sharedance.example.php

示例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);
开发者ID:ndobromirov,项目名称:php_course_2012,代码行数:31,代码来源:index.php


注:本文中的Timer::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。