Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / xsp / System / Web / Util / Profiler.cs / 1 / Profiler.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- /* * Profiler.cs * * Copyright (c) 2000 Microsoft Corporation */ namespace System.Web.Util { using System; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Threading; using System.Collections; internal class Profiler { private int _requestsToProfile; private Queue _requests; private bool _pageOutput; private bool _isEnabled; private bool _oldEnabled; private bool _localOnly; private bool _mostRecent; private TraceMode _outputMode; internal Profiler() { _requestsToProfile = 10; _outputMode = TraceMode.SortByTime; _localOnly = true; _mostRecent = false; _requests = new Queue(_requestsToProfile); } internal bool IsEnabled { get { return _isEnabled;} set { _isEnabled = value; _oldEnabled = value; } } internal bool PageOutput { get { // calling HttpContext.Current is slow, but we'll only get there if _pageOutput is true. return (_pageOutput && !(_localOnly && !HttpContext.Current.Request.IsLocal)); } set { _pageOutput = value; } } internal TraceMode OutputMode { get { return _outputMode;} set { _outputMode = value;} } internal bool LocalOnly { get { return _localOnly;} set { _localOnly = value; } } internal bool MostRecent { get { return _mostRecent; } set { _mostRecent = value; } } internal bool IsConfigEnabled { get { return _oldEnabled; } } internal int RequestsToProfile { get { return _requestsToProfile;} set { // VSWhidbey195368 Silently cap request limit at 10,000 if (value > 10000) { value = 10000; } _requestsToProfile = value; } } internal int RequestsRemaining { get { return _requestsToProfile - _requests.Count;} } internal void Reset() { // start profiling and clear the current log of requests _requests = new Queue(_requestsToProfile); if (_requestsToProfile != 0) _isEnabled = _oldEnabled; else _isEnabled = false; } internal void StartRequest(HttpContext context) { context.Trace.VerifyStart(); } internal void EndRequest(HttpContext context) { context.Trace.EndRequest(); // Don't add the trace data if we aren't enabled if (!IsEnabled) return; // grab trace data and add it to the list lock (_requests) { _requests.Enqueue(context.Trace.GetData()); // If we are storing the most recent, we may need to kick out the first request if (MostRecent) { if (_requests.Count > _requestsToProfile) _requests.Dequeue(); } } // Turn off profiling if we are only tracking the first N requests and we hit the limit. if (!MostRecent && _requests.Count >= _requestsToProfile) EndProfiling(); } internal void EndProfiling() { _isEnabled = false; } internal IList GetData() { return _requests.ToArray(); } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TextServicesHost.cs
- Utils.cs
- SignatureGenerator.cs
- PropertyGeneratedEventArgs.cs
- FontWeight.cs
- SplineKeyFrames.cs
- PopOutPanel.cs
- ObjectToken.cs
- MsmqIntegrationValidationBehavior.cs
- Rectangle.cs
- CodePropertyReferenceExpression.cs
- ToolBarButtonDesigner.cs
- HTTPNotFoundHandler.cs
- ProtocolsSection.cs
- selecteditemcollection.cs
- FileChangesMonitor.cs
- ObjectStateEntryDbUpdatableDataRecord.cs
- ToolStripItemImageRenderEventArgs.cs
- StaticSiteMapProvider.cs
- AffineTransform3D.cs
- GradientStop.cs
- ToolStripDesignerAvailabilityAttribute.cs
- FileLoadException.cs
- MessageHeaders.cs
- TraceContextRecord.cs
- Thickness.cs
- ItemCollection.cs
- RelationshipNavigation.cs
- GridViewSelectEventArgs.cs
- Label.cs
- BaseConfigurationRecord.cs
- SerializationHelper.cs
- IgnoreFileBuildProvider.cs
- DBSqlParser.cs
- Adorner.cs
- SymbolDocumentGenerator.cs
- PointValueSerializer.cs
- ObjectDataSourceSelectingEventArgs.cs
- DesignerView.xaml.cs
- PageHandlerFactory.cs
- ContractTypeNameCollection.cs
- X509ChainPolicy.cs
- LinqDataSourceHelper.cs
- RuleInfoComparer.cs
- SerialPinChanges.cs
- ExtendedPropertyDescriptor.cs
- StringOutput.cs
- SByteConverter.cs
- EmbeddedMailObjectsCollection.cs
- RegexCode.cs
- ObjectStateEntry.cs
- Facet.cs
- UrlPath.cs
- DecodeHelper.cs
- ResourceManager.cs
- EncoderBestFitFallback.cs
- SiteMapNodeItem.cs
- BatchParser.cs
- ScrollableControl.cs
- SimpleWorkerRequest.cs
- TemplateBamlTreeBuilder.cs
- thaishape.cs
- EntityParameter.cs
- WsatExtendedInformation.cs
- OrthographicCamera.cs
- RenamedEventArgs.cs
- XmlSchemaAppInfo.cs
- QueryHandler.cs
- DesignerDataParameter.cs
- DomainLiteralReader.cs
- ButtonBaseAutomationPeer.cs
- SqlFactory.cs
- PageSettings.cs
- MarkedHighlightComponent.cs
- EventLogPermissionAttribute.cs
- PrivilegeNotHeldException.cs
- StdRegProviderWrapper.cs
- ValueQuery.cs
- Code.cs
- EventLogReader.cs
- ZipFileInfoCollection.cs
- RuntimeConfig.cs
- CacheForPrimitiveTypes.cs
- DesignOnlyAttribute.cs
- Annotation.cs
- DataGridViewLinkColumn.cs
- DescendantQuery.cs
- ReadOnlyState.cs
- ChannelDispatcher.cs
- SizeIndependentAnimationStorage.cs
- FixedPageStructure.cs
- QuaternionConverter.cs
- FormViewDeleteEventArgs.cs
- SmiEventSink_DeferedProcessing.cs
- CachedFontFamily.cs
- Decimal.cs
- XsltOutput.cs
- OuterGlowBitmapEffect.cs
- Win32.cs
- GridViewItemAutomationPeer.cs