When I look at the performance counters in my service for the execution time of an operation, the value is always zero. Why?

There's a variety of reasons I can think of for why call data may not be collected and all are relatively easy to check.

First, you need to have performance counters enabled. The simplest way to do this is through configuration by setting the performanceCounters attribute to All in the diagnostics section. There are a few other performance counter scopes, some of which don't include the data you may be looking for.

Second, you need to have your application run long enough to collect data. During shutdown you may encounter races between the performance counters being freed and the remaining work being processed. Data isn't collected if the performance counters are not available.

Third, you need to have infrastructure support for collecting performance counter data. In a partially trusted environment you may not have sufficient permissions to perform management, logging, or performance counter operations.

Fourth, you need to have an operation that takes long enough to measure. You can't rely on getting high-precision timing measurements. Performance counters use cheap sampling methods to avoid interfering with application execution. If your application requires better than millisecond accuracy to collect data, then performance counters may be the wrong mechanism for measuring performance.