[ledger][benchmarks] Trace the duration of creating a cached instance of LevelDb.

Also added the results of the measurements in add_new_page(_precached).tspec
benchmarks.

Test: trace record --spec-file=/pkgfs/packages/ledger_benchmarks/0/data/add_new_page(_precached.tspec
Change-Id: I9fb316356b6ea29b321f13e8fcd6c52758944d18
diff --git a/bin/ledger/storage/impl/leveldb_factory.cc b/bin/ledger/storage/impl/leveldb_factory.cc
index 8486544..16920d5 100644
--- a/bin/ledger/storage/impl/leveldb_factory.cc
+++ b/bin/ledger/storage/impl/leveldb_factory.cc
@@ -8,6 +8,7 @@
 
 #include <lib/async/cpp/task.h>
 #include <lib/callback/scoped_callback.h>
+#include <lib/callback/trace_callback.h>
 #include <lib/fxl/files/directory.h>
 #include <lib/fxl/files/scoped_temp_dir.h>
 #include <lib/fxl/memory/ref_counted.h>
@@ -254,12 +255,14 @@
 
 void LevelDbFactory::PrepareCachedDb(
     CreateInStagingPath create_in_staging_path) {
+  TRACE_ASYNC_BEGIN("ledger", "prepare_cached_db", 0);
   FXL_DCHECK(!cached_db_is_ready_);
   FXL_DCHECK(cached_db_ == nullptr);
   GetOrCreateDbAtPath(
       cached_db_path_, create_in_staging_path,
       callback::MakeScoped(weak_factory_.GetWeakPtr(),
                            [this](Status status, std::unique_ptr<Db> db) {
+                             TRACE_ASYNC_END("ledger", "prepare_cached_db", 0);
                              cached_db_status_ = status;
                              cached_db_ = std::move(db);
                              cached_db_is_ready_ = true;
diff --git a/bin/ledger/tests/benchmark/get_page/add_new_page.tspec b/bin/ledger/tests/benchmark/get_page/add_new_page.tspec
index b800176..e9f6d68 100644
--- a/bin/ledger/tests/benchmark/get_page/add_new_page.tspec
+++ b/bin/ledger/tests/benchmark/get_page/add_new_page.tspec
@@ -12,6 +12,14 @@
       "event_category": "benchmark",
       "expected_sample_count": 50,
       "split_first": true
+    },
+    {
+      "type": "duration",
+      "output_test_name": "new_page/precache_db",
+      "event_name": "prepare_cached_db",
+      "event_category": "ledger",
+      "expected_sample_count": 50,
+      "split_first": true
     }
   ]
 }
diff --git a/bin/ledger/tests/benchmark/get_page/add_new_page_precached.tspec b/bin/ledger/tests/benchmark/get_page/add_new_page_precached.tspec
index e604a92..cfc621d 100644
--- a/bin/ledger/tests/benchmark/get_page/add_new_page_precached.tspec
+++ b/bin/ledger/tests/benchmark/get_page/add_new_page_precached.tspec
@@ -12,6 +12,14 @@
       "event_category": "benchmark",
       "expected_sample_count": 50,
       "split_first": true
+    },
+    {
+      "type": "duration",
+      "output_test_name": "new_page/precache_db",
+      "event_name": "prepare_cached_db",
+      "event_category": "ledger",
+      "expected_sample_count": 50,
+      "split_first": true
     }
   ]
 }