Select to view content in your preferred language

Performance of EditOperation.ExecuteAsync() operations

777
1
07-11-2017 11:07 PM
jackpearson
Emerging Contributor

Is there a known issue with performance of edit operations in V2 ?

I'm adding thousands of points to a filegeodb Point feature class
Using  a EditOperation.Create()  & MapPointBuilder.CreateMapPoint().

In v1.4 adding 3k points , the EditOp.ExecuteAsync() took 9 secs to execute,

Same code in v2.0 is now taking 70 secs.

Also, it now seems to scale poorly with larger datasets.

So for a more realistic operation of 50k points  is now taking 35 minutes !

Can anyone shed light on this ? is there a better way to be doing this ?

0 Kudos
1 Reply
CharlesMacleod
Esri Regular Contributor

Jeff, there is a known issue and we are working on it for 2.1  and it is probably the same as we determined for this post here: https://community.esri.com/thread/196147-poor-performance-when-creating-polylines

That said, this same performance issue will exist at 1.4 and 2.0 and I cannot reproduce your scenario where you have a drastic change in performance between 1.4 and 2.0. Can you post your code please so we can investigate further?

Using this sample on a dataset that comes with the Pro SDK samples (Interacting with Maps.gdb), It averages around 14 to 15 seconds on my laptop, running v2.0.

internal class TestEditOperation : Button
  {
    protected async override void OnClick()
    {
      var layer = MapView.Active.Map.GetLayersAsFlattenedList().First(l => l.Name == "Fire_Stations_1") as FeatureLayer;
      int limit = 3000;
      Stopwatch stopWatch = new Stopwatch();
      stopWatch.Start();
      await DoIt(layer, limit);

      stopWatch.Stop();
      TimeSpan ts = stopWatch.Elapsed;

      string elapsedTime = String.Format("{0:00}:{1:00}.{2:00}",
        ts.Minutes, ts.Seconds,
        ts.Milliseconds / 10);
      MessageBox.Show($"{limit} features = {elapsedTime}");
    }

    private Task<bool> DoIt(FeatureLayer layer, int limit)
    {
      return QueuedTask.Run(() =>
      {
        var sr = layer.GetSpatialReference();

        var qf = new QueryFilter();
        qf.WhereClause = "OBJECTID = 1";
        var rc = layer.Search(qf);
        rc.MoveNext();
        var shp = ((Feature)rc.Current).GetShape() as MapPoint;
        var station = Int32.Parse(rc.Current[2].ToString());
        station += 1000;
        var address = rc.Current[3];
        var city = rc.Current[4];
        var district = rc.Current[5];

        double d = 20.0;
        var op = new EditOperation();

        for (int i = 0; i < limit; i++, d += 10.0) {
          var attrib = new Dictionary<string, object>();
          attrib["SHAPE"] = MapPointBuilder.CreateMapPoint(shp.X + d, shp.Y, sr);
          attrib["STATION"] = $"{station++}";
          attrib["ADDRESS"] = address;
          attrib["CITY"] = city;
          attrib["DISTRICT"] = district;
          op.Create(layer, attrib);
        }
        return op.Execute();
      });
      
    }
  }
0 Kudos