MSDN Archive Home
Help and FAQs
All Resource Updates
Change History (all pages)
Scenario Home Page
A Scenario object is a highly-accurate timer that logs ETW events (Event Tracing for Windows) when you start and stop it. It's designed to be used for performance instrumentation and benchmarking, and comes in both C# and C++ versions.
Using a Scenario object is straightforward: simply create one, call Begin(), run the code that you want to benchmark, and then call End(). Between the calls to Begin() and End(), the Scenario object will track both elapsed time and thread-level CPU consumption using the most accurate available timers, and it will also log these times using ETW events. The ETW events can be post-processed by any ETW consumer, such as XPerf. Or you can ignore the event feature, and just read elapsed times directly from the fields of the Scenario object.
As a rule of thumb on modern hardware, a call to Begin() or End() takes on the order of a microsecond, and the resulting timestamps are accurate to 100ns (i.e. 0.1 microseconds).
Support and Distribution
The Scenario class is supported on Windows XP and above, although CPU time is only reported on Windows Vista and above. On XP it uses MOF-based ("classic") ETW events, while on Vista and above it uses XML-manifest ("Crimson") ETW events. Versions are available for both .NET 3.5 (written in C#), and native C++, and run on both x86 and x64 platforms. The Scenario class was originally developed using Visual Studio 2008, but is now targeted at developers using Visual Studio 2010.
How to Use It: The Basics
- all of the methods and properties
- code samples using the Scenario class
- answers to common questions and problems
- how to register the ETW provider
How To Use It: Advanced
- dos and don'ts for using Scenario objects
- the payload fields in ETW events from Scenario objects
We want to hear both! Join in on the "Discussions" tab, or if you're feeling adventurous you can add a bug or feature request on the "Issue Tracker" tab.
Oct 12 2009 at 3:45 AM
, version 11
Aug 15 2010 at 4:54 PM
It's worth mentioning that scenario markers are also supported within the VS Profiler.
Scenario Marker Support
Sign in to add a comment
Sun Oct 11 2009 at 7:00 AM
More Tags ...
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.