Пример #1
0
        $c = new Calendar_Minute($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i']);
        break;
    case 'calendar_second':
        require_once CALENDAR_ROOT . 'Second.php';
        $c = new Calendar_Second($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i'], $_GET['s']);
        break;
}
echo 'Viewing: ' . @$_GET['view'] . '<br />';
echo 'The time is now: ' . date('Y M d H:i:s', $c->getTimestamp()) . '<br >';
$i = 1;
echo '<h1>First Iteration</h1>';
echo '<p>The first iteration is more "expensive", the calendar data
        structures having to be built.</p>';
$start = getmicrotime();
$c->build();
while ($e = $c->fetch()) {
    $class = strtolower(get_class($e));
    $link = "&y=" . $e->thisYear() . "&m=" . $e->thisMonth() . "&d=" . $e->thisDay() . "&h=" . $e->thisHour() . "&i=" . $e->thisMinute() . "&s=" . $e->thisSecond();
    $method = 'this' . str_replace('calendar_', '', $class);
    echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?view=" . $class . $link . "\">" . $e->{$method}() . "</a> : ";
    if ($i % 10 == 0) {
        echo '<br>';
    }
    $i++;
}
echo '<p><b>Took: ' . (getmicrotime() - $start) . ' seconds</b></p>';
$i = 1;
echo '<h1>Second Iteration</h1>';
echo '<p>This second iteration is faster, the data structures
        being re-used</p>';
$start = getmicrotime();