protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataSpace.Text = ByteSizeFormatter.Format(MyDBDataset.Statistics.DataSpace); UsedSpace.Text = ByteSizeFormatter.Format(MyDBDataset.Statistics.UsedSpace); LogSpace.Text = ByteSizeFormatter.Format(MyDBDataset.Statistics.LogSpace); var used = (double)MyDBDataset.Statistics.UsedSpace / MyDBDataset.Statistics.DataSpace; var free = 1 - used; if (used == 0) { ProgressUsed.Visible = false; } else { ProgressUsed.Width = String.Format(CultureInfo.InvariantCulture, "{0}%", used * 100.0); } if (free == 0) { ProgressFree.Visible = false; } else { ProgressFree.Width = String.Format(CultureInfo.InvariantCulture, "{0}%", free * 100.0); } ProgressUsedLabel.Text = String.Format(CultureInfo.InvariantCulture, "{0:p}", free); RequestSpaceLink.NavigateUrl = Jhu.Graywulf.Web.Feedback.GetSpaceRequestUrl(); } }
/// <summary> /// Create one with memory counters in bytes /// </summary> public static ProcessMemoryCounters CreateFromBytes( ulong peakVirtualMemoryUsage, ulong peakWorkingSet, ulong peakCommitUsage) { return(new ProcessMemoryCounters( (int)ByteSizeFormatter.ToMegabytes(peakVirtualMemoryUsage), (int)ByteSizeFormatter.ToMegabytes(peakWorkingSet), (int)ByteSizeFormatter.ToMegabytes(peakCommitUsage))); }
protected override void UpdateForm() { base.UpdateForm(); FileGroup.EntityReference.Value = Item.FileGroup; Partition.EntityReference.Value = Item.Partition; AllocatedSpace.Text = ByteSizeFormatter.Format(Item.AllocatedSpace); UsedSpace.Text = ByteSizeFormatter.Format(Item.UsedSpace); // TODO ReservedSpace.Text = ByteSizeFormatter.Format(Item.ReservedSpace); // TODO }
public SMBItemViewModel(SMBItem smbItem) { IsDirectory = smbItem.IsDirectory; FileName = smbItem.Name; FilePath = smbItem.Path; LastWriteTime = smbItem.Info.LastWriteTime.ToLocalTime(); CreationTime = smbItem.Info.CreationTime.ToLocalTime(); Size = IsDirectory ? string.Empty : ByteSizeFormatter.Format((ulong)smbItem.Size); SMBItem = smbItem; }
public void Format_correctly_formats_size_with_decimal_convention(long size, string expected) { var formatter = new ByteSizeFormatter { Culture = CultureInfo.InvariantCulture, Convention = ByteSizeConvention.Decimal }; var actual = formatter.Format(size); Assert.Equal(expected, actual); }
protected override void OnSaveForm() { base.OnSaveForm(); Item.DiskVolumeReference.Guid = new Guid(DiskVolume.SelectedValue); Item.DatabaseFileType = (DatabaseFileType)Enum.Parse(typeof(DatabaseFileType), DatabaseFileType.SelectedValue); Item.LogicalName = LogicalName.Text; Item.Filename = Filename.Text; Item.AllocatedSpace = ByteSizeFormatter.Parse(AllocatedSpace.Text); Item.UsedSpace = ByteSizeFormatter.Parse(UsedSpace.Text); Item.ReservedSpace = ByteSizeFormatter.Parse(ReservedSpace.Text); }
protected override void UpdateForm() { base.UpdateForm(); FileGroupType.Text = Item.FileGroupType.ToString(); LayoutType.Text = Item.LayoutType.ToString(); AllocationType.Text = Item.AllocationType.ToString(); DiskVolumeType.Text = Item.DiskVolumeType.ToString(); FileGroupName.Text = Item.FileGroupName; AllocatedSpace.Text = ByteSizeFormatter.Format(Item.AllocatedSpace); FileCount.Text = Item.FileCount.ToString(); }
protected override void OnSaveForm() { base.OnSaveForm(); Item.FileGroupType = (FileGroupType)Enum.Parse(typeof(FileGroupType), fileGroupTypeList.SelectedValue); Item.LayoutType = (FileGroupLayoutType)Enum.Parse(typeof(FileGroupLayoutType), LayoutType.SelectedValue); Item.AllocationType = (FileGroupAllocationType)Enum.Parse(typeof(FileGroupAllocationType), allocationTypeList.SelectedValue); Item.DiskVolumeType = (DiskVolumeType)Enum.Parse(typeof(DiskVolumeType), diskVolumeTypeList.SelectedValue); Item.FileGroupName = FileGroupName.Text; Item.AllocatedSpace = ByteSizeFormatter.Parse(AllocatedSpace.Text); Item.FileCount = int.Parse(FileCount.Text); }
/// <summary> /// Create one with memory counters in bytes /// </summary> public static ProcessMemoryCounters CreateFromBytes( ulong peakWorkingSet, ulong averageWorkingSet, ulong peakCommitSize, ulong averageCommitSize) { return(new ProcessMemoryCounters( (int)ByteSizeFormatter.ToMegabytes(peakWorkingSet), (int)ByteSizeFormatter.ToMegabytes(averageWorkingSet), (int)ByteSizeFormatter.ToMegabytes(peakCommitSize), (int)ByteSizeFormatter.ToMegabytes(averageCommitSize))); }
/// <summary> /// Construct a new runtime data based on collected performance data /// </summary> public ProcessPipHistoricPerfData(ProcessPipExecutionPerformance executionPerformance) { Contract.Requires(executionPerformance.ExecutionLevel == PipExecutionLevel.Executed); m_entryTimeToLive = DefaultTimeToLive; // Deduct the suspended duration from the process execution time. DurationInMs = (uint)Math.Min(uint.MaxValue, Math.Max(1, executionPerformance.ProcessExecutionTime.TotalMilliseconds - executionPerformance.SuspendedDurationMs)); // For historical ram usage, we record the peak working set instead of the virtual memory due to the precision. MemoryCounters = executionPerformance.MemoryCounters; DiskIOInMB = (uint)Math.Min(uint.MaxValue, ByteSizeFormatter.ToMegabytes(executionPerformance.IO.GetAggregateIO().TransferCount)); ProcessorsInPercents = executionPerformance.ProcessorsInPercents; }
protected override void OnUpdateForm() { base.OnUpdateForm(); fileGroupTypeList.SelectedValue = Item.FileGroupType.ToString(); LayoutType.SelectedValue = Item.LayoutType.ToString(); allocationTypeList.SelectedValue = Item.AllocationType.ToString(); diskVolumeTypeList.SelectedValue = Item.DiskVolumeType.ToString(); FileGroupName.Text = Item.FileGroupName; AllocatedSpace.Text = ByteSizeFormatter.Format(Item.AllocatedSpace); FileCount.Text = Item.FileCount.ToString(); }
protected override void UpdateForm() { base.UpdateForm(); DiskVolume.EntityReference.Value = Item.DiskVolume; DatabaseFileType.Text = Item.DatabaseFileType.ToString(); LogicalName.Text = Item.LogicalName; filename.Text = Item.GetFullUncFilename(); filename.NavigateUrl = String.Format("file:{0}", Item.GetFullUncFilename().Replace('\\', '/')); AllocatedSpace.Text = ByteSizeFormatter.Format(Item.AllocatedSpace); UsedSpace.Text = ByteSizeFormatter.Format(Item.UsedSpace); ReservedSpace.Text = ByteSizeFormatter.Format(Item.ReservedSpace); }
protected override void OnUpdateForm() { base.OnUpdateForm(); RefreshDiskVolumeList(); DiskVolume.SelectedValue = Item.DiskVolumeReference.Guid.ToString(); DatabaseFileType.SelectedValue = Item.DatabaseFileType.ToString(); LogicalName.Text = Item.LogicalName; Filename.Text = Item.Filename; AllocatedSpace.Text = ByteSizeFormatter.Format(Item.AllocatedSpace); UsedSpace.Text = ByteSizeFormatter.Format(Item.UsedSpace); ReservedSpace.Text = ByteSizeFormatter.Format(Item.ReservedSpace); }
/// <summary> /// Choose a worker based on setup cost /// </summary> private Worker ChooseWorker(RunnablePip runnablePip, WorkerSetupCost[] workerSetupCosts, out WorkerResource?limitingResource) { if (MustRunOnMaster(runnablePip)) { // This is shortcut for the single-machine builds and distributed workers. return(LocalWorker.TryAcquire(runnablePip, out limitingResource, loadFactor: MaxLoadFactor) ? LocalWorker : null); } ResetStatus(); var pendingWorkerSelectionPipCount = PipQueue.GetNumQueuedByKind(DispatcherKind.ChooseWorkerCpu); bool loadBalanceWorkers = false; if (runnablePip.PipType == PipType.Process) { if (pendingWorkerSelectionPipCount + m_totalAcquiredProcessSlots < (m_totalProcessSlots / 2)) { // When there is a limited amount of work (less than half the total capacity of // the all the workers). We load balance so that each worker gets // its share of the work and the work can complete faster loadBalanceWorkers = true; } } long setupCostForBestWorker = workerSetupCosts[0].SetupBytes; limitingResource = null; foreach (var loadFactor in m_workerBalancedLoadFactors) { if (!loadBalanceWorkers && loadFactor < 1) { // Not load balancing so allow worker to be filled to capacity at least continue; } for (int i = 0; i < workerSetupCosts.Length; i++) { var worker = workerSetupCosts[i].Worker; if (worker.TryAcquire(runnablePip, out limitingResource, loadFactor: loadFactor)) { runnablePip.Performance.SetInputMaterializationCost(ByteSizeFormatter.ToMegabytes((ulong)setupCostForBestWorker), ByteSizeFormatter.ToMegabytes((ulong)workerSetupCosts[i].SetupBytes)); return(worker); } } } return(null); }
protected override void OnUpdateForm() { base.OnUpdateForm(); foreach (ListItem li in DiskVolumeType.Items) { li.Selected = ((Item.DiskVolumeType & (DiskVolumeType)Enum.Parse(typeof(DiskVolumeType), li.Value)) > 0); } LocalPath.Text = Item.LocalPath.Value; UncPath.Text = Item.UncPath.Value; FullSpace.Text = ByteSizeFormatter.Format(Item.FullSpace); AllocatedSpace.Text = ByteSizeFormatter.Format(Item.AllocatedSpace); ReservedSpace.Text = ByteSizeFormatter.Format(Item.ReservedSpace); Speed.Text = (Item.Speed / 100000.0).ToString("0.00"); }
public string FormatSize(double size) { var formatter = new ByteSizeFormatter { Convention = ByteSizeConvention.Binary, DecimalPlaces = 1, NumberFormat = "#,##0.###", MinUnit = ByteSizeUnit.Kilobyte, MaxUnit = ByteSizeUnit.Gigabyte, RoundingRule = ByteSizeRounding.Closest, UseFullWordForBytes = true, }; return(formatter.Format((long)size)); }
protected override void UpdateForm() { base.UpdateForm(); DiskVolumeType.Text = Item.DiskVolumeType.ToString(); LocalPath.Text = String.Format("{0} ({1})", Item.LocalPath.Value, Item.LocalPath.ResolvedValue); UncPath.Text = String.Format("{0} ({1})", Item.UncPath.Value, Item.UncPath.ResolvedValue); FullSpace.Text = ByteSizeFormatter.Format(Item.FullSpace); AllocatedSpace.Text = ByteSizeFormatter.Format(Item.AllocatedSpace); ReservedSpace.Text = ByteSizeFormatter.Format(Item.ReservedSpace); Speed.Text = (Item.Speed / 100000.0).ToString("0.00"); Usage.Values.Clear(); Usage.Values.Add((double)Item.AllocatedSpace / Item.FullSpace); Usage.Values.Add((double)Item.ReservedSpace / Item.FullSpace); }
public void FormatByteSize() { XAssert.AreEqual( "1 B", ByteSizeFormatter.Format(1)); XAssert.AreEqual( "1.00 KB", ByteSizeFormatter.Format(1024)); XAssert.AreEqual( "1.50 MB", ByteSizeFormatter.Format((1024 * 1024) + (512 * 1024) + 1)); XAssert.AreEqual( "999.00 GB", ByteSizeFormatter.Format(999L * 1024 * 1024 * 1024)); }
protected override void OnSaveForm() { base.OnSaveForm(); Item.DiskVolumeType = Registry.DiskVolumeType.Unknown; foreach (ListItem li in DiskVolumeType.Items) { if (li.Selected) { Item.DiskVolumeType |= (DiskVolumeType)Enum.Parse(typeof(DiskVolumeType), li.Value); } } Item.LocalPath.Value = LocalPath.Text; Item.UncPath.Value = UncPath.Text; Item.FullSpace = ByteSizeFormatter.Parse(FullSpace.Text); //item.AllocatedSpace = ByteSizeFormatter.ParseFileSize(AllocatedSpace.Text); // read only field Item.ReservedSpace = ByteSizeFormatter.Parse(ReservedSpace.Text); Item.Speed = (long)(double.Parse(Speed.Text) * 100000.0); }
/// <summary> /// Choose a worker based on setup cost /// </summary> private Worker ChooseWorker(RunnablePip runnablePip, WorkerSetupCost[] workerSetupCosts, out WorkerResource?limitingResource) { if (MustRunOnMaster(runnablePip)) { // This is shortcut for the single-machine builds and distributed workers. return(LocalWorker.TryAcquire(runnablePip, out limitingResource, loadFactor: MaxLoadFactor) ? LocalWorker : null); } ResetStatus(); var pendingWorkerSelectionPipCount = PipQueue.GetNumQueuedByKind(DispatcherKind.ChooseWorkerCpu) + PipQueue.GetNumRunningByKind(DispatcherKind.ChooseWorkerCpu); bool loadBalanceWorkers = false; if (runnablePip.PipType == PipType.Process) { if (pendingWorkerSelectionPipCount + m_totalAcquiredProcessSlots < (m_totalProcessSlots / 2)) { // When there is a limited amount of work (less than half the total capacity of // the all the workers). We load balance so that each worker gets // its share of the work and the work can complete faster loadBalanceWorkers = true; } } double?disableLoadBalanceMultiplier = EngineEnvironmentSettings.DisableLoadBalanceMultiplier; // Disable load-balance if there is a multiplier specified including 0. loadBalanceWorkers &= !disableLoadBalanceMultiplier.HasValue; long setupCostForBestWorker = workerSetupCosts[0].SetupBytes; limitingResource = null; foreach (var loadFactor in m_workerBalancedLoadFactors) { if (!loadBalanceWorkers && loadFactor < 1) { // Not load balancing so allow worker to be filled to capacity at least continue; } for (int i = 0; i < workerSetupCosts.Length; i++) { var worker = workerSetupCosts[i].Worker; if (worker.TryAcquire(runnablePip, out limitingResource, loadFactor: loadFactor)) { runnablePip.Performance.SetInputMaterializationCost(ByteSizeFormatter.ToMegabytes((ulong)setupCostForBestWorker), ByteSizeFormatter.ToMegabytes((ulong)workerSetupCosts[i].SetupBytes)); return(worker); } // If the worker is not chosen due to the lack of process slots, // do not try the next worker immediately if 'BuildXLDisableLoadBalanceMultiplier' is specified. // We first check whether the number of pips waiting for a worker is less than the total slots times with the multiplier. // For example, if the multiplier is 1 and totalWorkerSlots is 100, then we do not try the next worker // if there are less than 100 pips waiting for a worker. // For Cosine builds, executing pips on a new worker is expensive due to the input materialization. // It is usually faster to wait for the busy worker to be available compared to trying on another worker. if (limitingResource == WorkerResource.AvailableProcessSlots && disableLoadBalanceMultiplier.HasValue && pendingWorkerSelectionPipCount < (worker.TotalProcessSlots * disableLoadBalanceMultiplier.Value)) { limitingResource = WorkerResource.DisableLoadBalance; return(null); } } } return(null); }
public void WhenDataExceedsMegabyte_ThenVolumeShownAsMB() { var volume = 2ul * 1024 * 1024; Assert.AreEqual("2 MB", ByteSizeFormatter.Format(volume)); }
public void WhenDataExceedsKilobyte_ThenVolumeShownAsKB() { var volume = 2ul * 1024 + 200; Assert.AreEqual("2.2 KB", ByteSizeFormatter.Format(volume)); }
public void WhenDataLessThanKilobyte_ThenVolumeShownAsB() { var volume = 765ul; Assert.AreEqual("765 B", ByteSizeFormatter.Format(volume)); }