Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Shared / MS / Utility / PerfService.cs / 1305600 / PerfService.cs
//---------------------------------------------------------------------------- //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Implements the Service class for perf diagnostics //--------------------------------------------------------------------------- using System; using System.Text; using System.Windows; using System.Collections.Generic; using Microsoft.Win32; using MS.Internal.PresentationCore; using MS.Internal; using MS.Utility; using MS.Win32.PresentationCore; using System.Reflection; namespace MS.Utility { [FriendAccessAllowed] static internal class PerfService { // Box the long to avoid JIT private static DictionaryperfElementIds = new Dictionary (); /// /// Perfservice uses this property to uniquely identfy each element in the tree. /// this ID gets traced with ETW traces and gets mapped to the element in the tool /// value is valid only if the service is running /// internal static long GetPerfElementID2(object element, string extraData) { object eltId = null; int hash = element.GetHashCode(); lock (perfElementIds) { if (!perfElementIds.TryGetValue(hash, out eltId)) { eltId = SafeNativeMethods.GetNextPerfElementId(); perfElementIds.Add(hash, eltId); // If this is the first time we see this object emit some useful info about it. if (EventTrace.IsEnabled(EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Verbose)) { Type type = element.GetType(); Assembly asm = type.Assembly; EventTrace.EventProvider.TraceEvent(EventTrace.Event.PerfElementIDAssignment, EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Verbose, (long)eltId, type.FullName, extraData, GetPerfElementID2(asm, asm.FullName)); } } } return (long)eltId; } internal static long GetPerfElementID(object element) { return GetPerfElementID2(element, string.Empty); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- //// Copyright (C) Microsoft Corporation. All rights reserved. // // // Description: Implements the Service class for perf diagnostics //--------------------------------------------------------------------------- using System; using System.Text; using System.Windows; using System.Collections.Generic; using Microsoft.Win32; using MS.Internal.PresentationCore; using MS.Internal; using MS.Utility; using MS.Win32.PresentationCore; using System.Reflection; namespace MS.Utility { [FriendAccessAllowed] static internal class PerfService { // Box the long to avoid JIT private static DictionaryperfElementIds = new Dictionary (); /// /// Perfservice uses this property to uniquely identfy each element in the tree. /// this ID gets traced with ETW traces and gets mapped to the element in the tool /// value is valid only if the service is running /// internal static long GetPerfElementID2(object element, string extraData) { object eltId = null; int hash = element.GetHashCode(); lock (perfElementIds) { if (!perfElementIds.TryGetValue(hash, out eltId)) { eltId = SafeNativeMethods.GetNextPerfElementId(); perfElementIds.Add(hash, eltId); // If this is the first time we see this object emit some useful info about it. if (EventTrace.IsEnabled(EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Verbose)) { Type type = element.GetType(); Assembly asm = type.Assembly; EventTrace.EventProvider.TraceEvent(EventTrace.Event.PerfElementIDAssignment, EventTrace.Keyword.KeywordGeneral, EventTrace.Level.Verbose, (long)eltId, type.FullName, extraData, GetPerfElementID2(asm, asm.FullName)); } } } return (long)eltId; } internal static long GetPerfElementID(object element) { return GetPerfElementID2(element, string.Empty); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpCachePolicyWrapper.cs
- RegexWorker.cs
- XamlTreeBuilder.cs
- AttributedMetaModel.cs
- SqlServer2KCompatibilityAnnotation.cs
- RadialGradientBrush.cs
- HtmlElementEventArgs.cs
- ValidationErrorEventArgs.cs
- MatrixCamera.cs
- DataStreamFromComStream.cs
- WebPartHeaderCloseVerb.cs
- PeerMaintainer.cs
- CalendarDay.cs
- WebPartDisplayModeCancelEventArgs.cs
- dtdvalidator.cs
- DataGridViewTextBoxCell.cs
- EntityConnectionStringBuilder.cs
- UnauthorizedAccessException.cs
- ServiceHostFactory.cs
- RTLAwareMessageBox.cs
- XamlTreeBuilderBamlRecordWriter.cs
- SessionEndingEventArgs.cs
- XmlHierarchicalEnumerable.cs
- GradientBrush.cs
- BitmapMetadataBlob.cs
- XmlAttributeProperties.cs
- UnsafeNativeMethods.cs
- Drawing.cs
- DesignerDataStoredProcedure.cs
- MetadataPropertyvalue.cs
- ListBoxItemAutomationPeer.cs
- WizardStepBase.cs
- DataColumnMapping.cs
- BlurEffect.cs
- PiiTraceSource.cs
- ExpandedWrapper.cs
- BookmarkOptionsHelper.cs
- StylusButtonCollection.cs
- Tuple.cs
- DataColumnCollection.cs
- OutKeywords.cs
- ToolStripScrollButton.cs
- UrlEncodedParameterWriter.cs
- RenderDataDrawingContext.cs
- FrameworkContentElement.cs
- DesignerAdapterAttribute.cs
- BooleanAnimationBase.cs
- BufferedWebEventProvider.cs
- InputScopeAttribute.cs
- EntitySqlQueryCacheKey.cs
- FileFormatException.cs
- SchemaImporter.cs
- HandledMouseEvent.cs
- ReadOnlyDataSource.cs
- Decoder.cs
- SafeRegistryHandle.cs
- RoleManagerEventArgs.cs
- WebPartExportVerb.cs
- StylusCollection.cs
- HitTestResult.cs
- ThreadStaticAttribute.cs
- EventLogEntry.cs
- EventLogPermissionEntry.cs
- DragEvent.cs
- userdatakeys.cs
- SourceSwitch.cs
- XslException.cs
- TabItemWrapperAutomationPeer.cs
- DesignSurfaceManager.cs
- MatrixValueSerializer.cs
- FastEncoderWindow.cs
- WindowsSysHeader.cs
- XamlTreeBuilder.cs
- OraclePermissionAttribute.cs
- PropertyRecord.cs
- CqlQuery.cs
- Size.cs
- basecomparevalidator.cs
- IconConverter.cs
- ContractBase.cs
- GeneralTransformGroup.cs
- ListItemConverter.cs
- XmlChoiceIdentifierAttribute.cs
- OperatingSystem.cs
- CompilationUnit.cs
- BuildProviderAppliesToAttribute.cs
- KeyboardEventArgs.cs
- TypedElement.cs
- CaseInsensitiveHashCodeProvider.cs
- PointHitTestResult.cs
- PathParser.cs
- TreeNodeBinding.cs
- ChangeProcessor.cs
- Point3DValueSerializer.cs
- RangeValidator.cs
- CompletedAsyncResult.cs
- InternalSendMessage.cs
- EtwTrace.cs
- MdiWindowListItemConverter.cs
- MostlySingletonList.cs