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; }
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) {