[GIS] Measuring draw time of layer in ArcMap

add-inarcgis-desktoparcmaparcobjectsperformance

I'd like to quantitatively measure the display performance of mosaic datasets, image service layers, raster layers, feature layers, etc. in ArcMap 10.

How can I measure the draw time of a particular layer (or the complete drawing process if that is the only option) in ArcMap? What are the interfaces, objects and events involved? Is the StopWatch class in .NET suitable for accurately measuring this type of operation?

Has anyone already created an ArcMap add-in or extension for this purpose?

Best Answer

I'm not sure how accurate this is, but I've done this in the past:

Create a LayerExtension class that implements ILayerExtensionDraw. Within the class keep a list of timings. A Timing is a class with a start tick and an end tick property. When BeforeLayerDraw is called for esriDPGeography, instantiate a new timing intance and set the StartTick property to Environment.TickCount. When AfterLayerDraw is called for esriDPGeography set the EndTick to Environment.TickCount and add it to the list.

In looking at this answer, I'd say you're better off using StopWatch than TickCount.

Add the LayerExtension to the layer via ILayerExtensions.Add method. Do not keep a strong reference to the ILayer within the layerextension.

Write a button that lets you add and clear layerextensions from layers in the map.

Write a button that loops through each layer and lists average, max, min etc. drawtimes for each layer.

I've also considered adding other properties to the layerextension to monitor for things like cpu, disk i/o, etc. but never got around to it.

Related Question