
This CL removes the default value of the `tag` argument on the 2
`sql::Database` constructors, and updates all callers that didn't
explicitly pass a tag to do so.
As a convenience, this CL also defines a common tag for unit tests.
This will allow the implementation and monitoring of per-database
performance metrics (time to open, statement execution time, VMSteps,
etc) without the possibility of having some of the databases
uninstrumented. This is useful for diagnosing issues such as crbug.com/369635654 in the wild, and required for some performance investigations that we have in the pipeline.
The last step of this work item (asserting that the tag is correctly defined in histograms.xml variants) is implemented in https://chromium-review.googlesource.com/c/chromium/src/+/6055279.
Bug: 40949392
Change-Id: I6dec0fb86a5e7b98cd42ac3a9db18e23eaf9e9bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6039025
Reviewed-by: manuk hovanesian <manukh@chromium.org>
Commit-Queue: Anthony Vallée-Dubois <anthonyvd@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1395446}
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
// Copyright 2015 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "sql/sql_memory_dump_provider.h"
|
|
|
|
#include "base/files/scoped_temp_dir.h"
|
|
#include "base/trace_event/memory_dump_request_args.h"
|
|
#include "base/trace_event/process_memory_dump.h"
|
|
#include "sql/database.h"
|
|
#include "sql/test/test_helpers.h"
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
|
|
|
namespace sql {
|
|
|
|
namespace {
|
|
|
|
class SQLMemoryDumpProviderTest : public testing::Test {
|
|
public:
|
|
void SetUp() override {
|
|
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
|
ASSERT_TRUE(db_.Open(
|
|
temp_dir_.GetPath().AppendASCII("memory_dump_provider_test.sqlite")));
|
|
|
|
ASSERT_TRUE(db_.Execute("CREATE TABLE foo (a, b)"));
|
|
}
|
|
|
|
protected:
|
|
base::ScopedTempDir temp_dir_;
|
|
Database db_{test::kTestTag};
|
|
};
|
|
|
|
TEST_F(SQLMemoryDumpProviderTest, OnMemoryDump) {
|
|
base::trace_event::MemoryDumpArgs args = {
|
|
base::trace_event::MemoryDumpLevelOfDetail::kDetailed};
|
|
base::trace_event::ProcessMemoryDump pmd(args);
|
|
ASSERT_TRUE(SqlMemoryDumpProvider::GetInstance()->OnMemoryDump(args, &pmd));
|
|
ASSERT_TRUE(pmd.GetAllocatorDump("sqlite"));
|
|
}
|
|
|
|
} // namespace
|
|
|
|
} // namespace sql
|