3s4d

the performance FGDB API & Arcobjects

Discussion created by 3s4d on Aug 9, 2011
Latest reply on Aug 3, 2012 by elbison
Hi, I test insert 50,000 points to a FeatureClass use  FGDB API  & ArcObjects

But the result is ArcObjects fast than FGDB API :
ArcObjects used time:
Testing with 50,000 points.
Total time taken: 20.5 s

FGDB API used time:
Testing with 50,000 points.
Total time taken: 80.4 s


My IDE is Visual studio 2010 C++
FGDB API is Final 1.0 version
ArcObjects 10 version

Is not FGDB API faster than ArcObjects ?  

Below is FGDB API  code :
fgdbError hr;
  wstring   errorText;
  // Open the geodatabase.
  Geodatabase geodatabase;
  if ((hr = OpenGeodatabase(L"F:/testData/Editing.gdb", geodatabase)) != S_OK)
  {
    wcout << "An error occurred while opening the geodatabase." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return ;
  }
  // Open the Cities table.
  Table table;
  if ((hr = geodatabase.OpenTable(L"\\Cities", table)) != S_OK)
  {
    wcout << "An error occurred while opening the table." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return ;
  }

  Row cabazonRow;
  PointShapeBuffer cabazonGeom;
  Point* point;
   for (int i = 0; i < 50000; i++)
  {
   // Create a new feature for Cabazon.
   table.CreateRowObject(cabazonRow);

   // Set the row's attributes.
   cabazonRow.SetString(L"AREANAME", L"Cabazon");
   cabazonRow.SetString(L"CLASS", L"town");
   cabazonRow.SetInteger(L"POP2000", 2939); // 2007

   // Create and assign a point geometry.
   hr = cabazonGeom.Setup(shapePoint);
   hr = cabazonGeom.GetPoint(point);

   point->x = -116.78443;
   point->y =   33.919902;

   cabazonRow.SetGeometry(cabazonGeom);

   hr = table.Insert(cabazonRow);

  //// Store the row.
  //if ((hr = table.Insert(cabazonRow)) != S_OK)
  //{
  //  wcout << "An error occurred while inserting a row." << endl;
  //  ErrorInfo::GetErrorDescription(hr, errorText);
  //  wcout << errorText << "(" << hr << ")." << endl;
  //  return ;
  //}
  //else
  //{
  //  wcout << "Inserted two strings, one integer and a point." << endl;
  //}

  }

Outcomes