public function GetLayout(Date $date, $resourceId) { try { $hideBlocked = Configuration::Instance()->GetSectionKey(ConfigSection::SCHEDULE, ConfigKeys::SCHEDULE_HIDE_BLOCKED_PERIODS, new BooleanConverter()); $sw = new StopWatch(); $sw->Start(); $items = $this->_reservationListing->OnDateForResource($date, $resourceId); $sw->Record('listing'); $list = new ScheduleReservationList($items, $this->_scheduleLayout, $date, $hideBlocked); $slots = $list->BuildSlots(); $sw->Record('slots'); $sw->Stop(); Log::Debug('DailyLayout::GetLayout - For resourceId %s on date %s, took %s seconds to get reservation listing, %s to build the slots, %s total seconds for %s reservations. Memory consumed=%sMB', $resourceId, $date->ToString(), $sw->GetRecordSeconds('listing'), $sw->TimeBetween('slots', 'listing'), $sw->GetTotalSeconds(), count($items), round(memory_get_usage() / 1048576, 2)); return $slots; } catch (Exception $ex) { Log::Error('Error getting layout on date %s for resourceId %s. Exception=%s', $date->ToString(), $resourceId, $ex); throw $ex; } }
public function GetAttributes($category, $entityIds = array()) { if (!is_array($entityIds) && !empty($entityIds)) { $entityIds = array($entityIds); } $attributeList = new AttributeList(); $attributes = $this->attributeRepository->GetByCategory($category); $stopwatch = new StopWatch(); $stopwatch->Start(); $values = $this->attributeRepository->GetEntityValues($category, $entityIds); foreach ($attributes as $attribute) { $attributeList->AddDefinition($attribute); } foreach ($values as $value) { $attributeList->AddValue($value); } $stopwatch->Stop(); Log::Debug('Took %d seconds to load custom attributes for category %s', $stopwatch->GetTotalSeconds(), $category); return $attributeList; }
require_once ROOT_DIR . 'tests/TestBase.php'; $tests = array('Domain/Reservation/ReservationViewRepositoryTests.php', 'Domain/Reservation/AdminEmailNotificationTests.php', 'Domain/Reservation/OwnerEmailNotificationTests.php', 'Domain/Reservation/ReservationDateTimeRuleTests.php', 'Domain/PermissionValidationRuleTests.php', 'Domain/ResourceAvailabilityRuleTests.php', 'Domain/AddReservationValidationServiceTests.php', 'PresenterTests/EditReservationPresenterTests.php', 'PresenterTests/ReservationSavePresenterTests.php', 'Domain/RepeatOptionsTests.php', 'Domain/ReservationTests.php', 'Domain/UserRepositoryTests.php', 'Domain/ReservationRepositoryTests.php', 'PresenterTests/NewReservationPresenterTests.php', 'PresenterTests/ReservationInitializationTests.php', 'PresenterTests/NewReservationPreconditionServiceTests.php', 'ScheduleUserRepositoryTests.php', 'ResourcePermissionStoreTests.php', 'PermissionServiceTests.php', 'DateTests.php', 'ReservationListingTests.php', 'ScheduleLayoutTests.php', 'DailyLayoutTests.php', 'SchedulePresenterTests.php', 'ReservationServiceTests.php', 'ScheduleReservationListTests.php', 'ResourceRepositoryTestsitoryTests.php', 'SchedulesTests.php', 'AnnouncementRepositoryTeststoryTests.php', 'AnnouncementPresenterTests.php', 'PluginManagerTests.php', 'ConfigTests.php', 'ActiveDirectoryTests.php', 'RegisterPresenterTests.php', 'ValidatorTests.php', 'PasswordMigrationTests.php', 'ResourcesTests.php', 'LoginPresenterTests.php', 'DatabaseTests.php', 'DatabaseCommandTests.php', 'AuthorizationTests.php', 'PasswordEncryptionTests.php', 'RegistrationTests.php', 'SmartyControlTests.php'); /* $tests = array( 'SchedulePresenterTests.php', 'ResourceRepositoryTests.phpyTests.php', 'DateTests.php', 'ScheduleReservationListTests.php'); */ $passed = true; $totalRun = 0; $totalPassed = 0; $totalFailed = 0; $totalTimer = new StopWatch(); $totalTimer->Start(); $suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework'); for ($i = 0; $i < count($tests); $i++) { require_once $tests[$i]; $fileWithDir = explode('/', $tests[$i]); $fileName = $tests[$i]; if (count($fileWithDir) > 1) { $fileName = $fileWithDir[count($fileWithDir) - 1]; } $name_parts = explode('.', $fileName); $name = $name_parts[0]; //$suite->addTestFile($tests[$i]); $suite->addTestSuite($name); } PHPUnit_TextUI_TestRunner::run($suite); $totalTimer->Stop();
$startResource = rand(0, $howManyResources); if ($period->IsReservable()) { for ($resourceNum = $startResource; $resourceNum < $howManyResources; $resourceNum++) { $userId = getRandomUserId($users)->Id(); $resource = $resources[$resourceNum]; $date = new DateRange($period->BeginDate(), $period->EndDate(), 'America/Chicago'); $reservation = ReservationSeries::Create($userId, $resource, "load{$i}", null, $date, new RepeatNone(), $bookedBy); $reservationRepo->Add($reservation); $i++; } } } $currentDate = $currentDate->AddDays(1); } echo "Loaded {$numberOfReservations} reservations<br/>"; $stopWatch->Stop(); echo "<h5>Took " . $stopWatch->GetTotalSeconds() . " seconds</h5>"; /** * @param array|User[] $users * @return User */ function getRandomUserId($users) { $rand = rand(0, count($users) - 1); return $users[$rand]; } /** * @param array|BookableResource[] $resources * @return BookableResource */ function getRandomResource($resources)
// Set default page // Set default page case 'page_default': Editor::SetDefaultPage($_POST['page_id']); exit; default: exit; } } else { print Editor::GetPage($pageid); } } else { $pagename = isset($_GET['page']) ? $_GET['page'] : 'index'; print Content::GetPage($pageid); } StopWatch::Stop(); print "<br/><br/><h1>Execution took " . StopWatch::GetTotal() . "ms with " . Database::$queries . " queries</h1>"; //print "<br/><br/>"; /* if ($_GET['action'] == "login") { if (!$core->Account->m_loggedin) { if ($core->Account->Login($_GET['username'], $_GET['password'], false)) print "Login successful!<br/>"; else print "Login failed<br/>"; } else { print "Your'e already logged in!<br/>"; } } if ($_GET['action'] == "logout") {