[benchmarks] More tests: create, destroy, parent

Benchmark:
 - Creation and destruction of metrics and properties
 - Making one object the parent of another, and then breaking the link.
 - Double addition and double removal. (It's interesting.)

Test: /pkgfs/packages/instrumentation_benchmarks/0/test/instrumentation_benchmarks -p
CF-205 #progress

Change-Id: I8442345358389d8ae3846145b3f15f409b18675d
diff --git a/bin/instrumentation_benchmarks/inspect.cc b/bin/instrumentation_benchmarks/inspect.cc
index e100834..ca847ba 100644
--- a/bin/instrumentation_benchmarks/inspect.cc
+++ b/bin/instrumentation_benchmarks/inspect.cc
@@ -53,6 +53,26 @@
 };
 
 // Measure the time taken to increment an IntMetric.
+bool TestCreationAndDestruction(perftest::RepeatState* state) {
+  state->DeclareStep("CreateMetric");
+  state->DeclareStep("DestroyMetric");
+  state->DeclareStep("CreateProperty");
+  state->DeclareStep("DestroyProperty");
+  while (state->KeepRunning()) {
+    {
+      NumericItem item;
+      state->NextStep();
+    }
+    state->NextStep();
+    {
+      PropertyItem item;
+      state->NextStep();
+    }
+  }
+  return true;
+}
+
+// Measure the time taken to increment an IntMetric.
 bool TestIncrement(perftest::RepeatState* state) {
   NumericItem item;
   while (state->KeepRunning()) {
@@ -92,8 +112,43 @@
   return true;
 }
 
+bool TestParentage(perftest::RepeatState* state) {
+  NumericItem parent;
+  NumericItem child1;
+  NumericItem child2;
+  NumericItem child3;
+  state->DeclareStep("AddFirst");
+  state->DeclareStep("AddSecond");
+  state->DeclareStep("AddFirstAgain");
+  state->DeclareStep("AddThird");
+  state->DeclareStep("RemoveFirst");
+  state->DeclareStep("RemoveSecond");
+  state->DeclareStep("RemoveFirstAgain");
+  state->DeclareStep("RemoveThird");
+  while (state->KeepRunning()) {
+    child1.set_parent(parent.object_dir());
+    state->NextStep();
+    child2.set_parent(parent.object_dir());
+    state->NextStep();
+    child1.set_parent(parent.object_dir());
+    state->NextStep();
+    child3.set_parent(parent.object_dir());
+    state->NextStep();
+    child1.remove_from_parent();
+    state->NextStep();
+    child2.remove_from_parent();
+    state->NextStep();
+    child1.remove_from_parent();
+    state->NextStep();
+    child3.remove_from_parent();
+  }
+  return true;
+}
+
 void RegisterTests() {
+  perftest::RegisterTest("Inspect/CreateDestroy", TestCreationAndDestruction);
   perftest::RegisterTest("Inspect/Increment", TestIncrement);
+  perftest::RegisterTest("Inspect/Parentage", TestParentage);
   perftest::RegisterTest("Inspect/Path0", TestIncrementPath, kPath0);
   perftest::RegisterTest("Inspect/Path1", TestIncrementPath, kPath1);
   perftest::RegisterTest("Inspect/Path2", TestIncrementPath, kPath2);