You want to look into the WPF Performance Suite. From MSDN:
The Windows SDK includes a suite of performance profiling tools for Windows Presentation Foundation (WPF) applications called the WPF Performance Suite. The WPF Performance Suite enables you to analyze the run-time behavior of your WPF applications and determine performance optimizations that you can apply. The WPF Performance Suite includes performance profiling tools called Perforator and Visual Profiler.
If you're looking to measure just the time in a particular body of code (essentially in your source code) - you're going to need to look at a performance profiler. RedGate sells a profiler I like - but there are others. Doing this directly in your code so that you can log it yourself will be difficult. You could certainly capture the timing information - but that will itself skew the results.