I am having a performance issue with ArcGIS Pro (1.4). I need to create a map programmatically that contains about 50 layers.
The tests were performed under Windows 10 Pro via VMware running on a Macbook Pro with an i7 @ 3.10 ghz. The tests were repeated when the VM was set up with 4gb, 8gb, and 12gb allocated ram with no appreciable difference. The layer being added is a polyline spatial type. The test was run with a feature class containing 1188 features and again with a feature class containing 81267 features also with no appreciable difference. The layer is file geodatabased and is on the local drive.
I ran the code sample below in VS2015 six times with the loop count changed and successive uncommenting of the tests:
Test 25 layers ms 50 layer ms
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: CreateLayer only: 8905 16990
2: CreateLayer + FeatureLayer: 8998 16817
3: CreateLayer + FeatureLayer + Selectable: 11241 22149
// For demonstrating the ArcGIS Pro slow map layer creation issue. We are
// trying to create a map containing 50 layers. The test was run on Pro 1.4.
internal static async Task LayerPerformanceTest()
{
ArcGIS.Desktop.Mapping.Map map = null;
int ms = 0; // for performance test in milliseconds.
Task loadMap = QueuedTask.Run(() =>
{
// Create new map and set it's spatial ref.
map = MapFactory.CreateMap("LayerTest");
SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(2227);
map.SetSpatialReference(sr);
// Create a grouplayer to contain the newly created layers.
GroupLayer groupLayer = GetOrCreateGroupLayer(map);
// Append the same layer 50 times.
string url = "c:\\Data\\COA\\FeatureEsri\\CadasterCogo.gdb\\ASR_RowLine";
DateTime dt1 = DateTime.Now;
for (int i = 0; i < 50; i++)
{
// Test 1:
LayerFactory.CreateLayer(new Uri(url), groupLayer, 0, "Layer " + i.ToString());
// Test 2, add:
// FeatureLayer featureLayer = groupLayer.Layers[0] as FeatureLayer;
// Test 3 add:
// var cimFeatureDefinition = featureLayer.GetDefinition() as ArcGIS.Core.CIM.CIMFeatureLayer;
// cimFeatureDefinition.Selectable = false;
// featureLayer.SetDefinition(cimFeatureDefinition);
}
DateTime dt2 = DateTime.Now;
TimeSpan span = dt2 - dt1;
ms = (int)span.TotalMilliseconds;
});
// Wait (not blocking) until the task is done. (loadMap.Wait() blocks).
await loadMap;
// Add the new map to the panes collection.
var newPane = await ArcGIS.Desktop.Framework.FrameworkApplication.Panes.CreateMapPaneAsync(map);
}