OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/files/scoped_file.h" | 7 #include "base/files/scoped_file.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/statistics_recorder.h" | |
11 #include "base/test/histogram_tester.h" | |
10 #include "sql/connection.h" | 12 #include "sql/connection.h" |
11 #include "sql/meta_table.h" | 13 #include "sql/meta_table.h" |
14 #include "sql/proxy.h" | |
12 #include "sql/statement.h" | 15 #include "sql/statement.h" |
13 #include "sql/test/error_callback_support.h" | 16 #include "sql/test/error_callback_support.h" |
14 #include "sql/test/scoped_error_ignorer.h" | 17 #include "sql/test/scoped_error_ignorer.h" |
15 #include "sql/test/test_helpers.h" | 18 #include "sql/test/test_helpers.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/sqlite/sqlite3.h" | 20 #include "third_party/sqlite/sqlite3.h" |
18 | 21 |
22 namespace sql { | |
23 namespace test { | |
24 | |
25 // Replaces the database time source with an object that steps forward 1ms on | |
26 // each check, and which can be jumped forward an arbitrary amount of time | |
27 // programmatically. | |
28 class ScopedMockTimeSource { | |
29 public: | |
30 ScopedMockTimeSource(Connection& db) | |
31 : db_(db), | |
32 delta_(base::TimeDelta::FromMilliseconds(1)) { | |
33 // Save the current source and replace it. | |
34 save_.swap(db_.clock_); | |
35 db_.clock_.reset(new MockTimeSource(*this)); | |
36 } | |
37 ~ScopedMockTimeSource() { | |
38 // Put original source back. | |
39 db_.clock_.swap(save_); | |
40 } | |
41 | |
42 void adjust(const base::TimeDelta& delta) { | |
43 current_time_ += delta; | |
44 } | |
45 | |
46 private: | |
47 class MockTimeSource : public TimeSource { | |
48 public: | |
49 MockTimeSource(ScopedMockTimeSource& owner) | |
50 : owner_(owner) { | |
51 } | |
52 ~MockTimeSource() override {} | |
53 | |
54 base::TimeTicks Now() override { | |
55 base::TimeTicks ret(owner_.current_time_); | |
56 owner_.current_time_ += owner_.delta_; | |
57 return ret; | |
58 } | |
59 | |
60 private: | |
61 ScopedMockTimeSource& owner_; | |
62 DISALLOW_COPY_AND_ASSIGN(MockTimeSource); | |
63 }; | |
64 | |
65 Connection& db_; | |
66 | |
67 // Saves original source from |db_|. | |
68 scoped_ptr<TimeSource> save_; | |
69 | |
70 // Current time returned by mock. | |
71 base::TimeTicks current_time_; | |
72 | |
73 // How far to jump on each Now() call. | |
74 base::TimeDelta delta_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(ScopedMockTimeSource); | |
77 }; | |
78 | |
79 // Allow a test to add a SQLite function in a scoped context. | |
80 class ScopedScalarFunction { | |
81 public: | |
82 ScopedScalarFunction( | |
83 sql::Connection& db, | |
84 const char* function_name, | |
85 int args, | |
86 base::Callback<void(sqlite3_context*,int,sqlite3_value**)> cb) | |
87 : db_(db.db_), function_name_(function_name), cb_(cb) { | |
88 sql::sqlite3_create_function_v2(db_, function_name, args, SQLITE_UTF8, | |
89 this, &Run, NULL, NULL, NULL); | |
90 } | |
91 ~ScopedScalarFunction() { | |
92 sql::sqlite3_create_function_v2(db_, function_name_, 0, SQLITE_UTF8, | |
93 NULL, NULL, NULL, NULL, NULL); | |
94 } | |
95 | |
96 private: | |
97 static void Run(sqlite3_context* context, int argc, sqlite3_value** argv) { | |
98 ScopedScalarFunction* t = static_cast<ScopedScalarFunction*>( | |
99 sqlite3_user_data(context)); | |
100 t->cb_.Run(context, argc, argv); | |
101 } | |
102 | |
103 sqlite3* db_; | |
104 const char* function_name_; | |
105 base::Callback<void(sqlite3_context*,int,sqlite3_value**)> cb_; | |
106 | |
107 DISALLOW_COPY_AND_ASSIGN(ScopedScalarFunction); | |
108 }; | |
109 | |
110 // Allow a test to add a SQLite commit hook in a scoped context. | |
111 class ScopedCommitHook { | |
112 public: | |
113 ScopedCommitHook(sql::Connection& db, | |
114 base::Callback<int(void)> cb) | |
115 : db_(db.db_), | |
116 cb_(cb) { | |
117 sql::sqlite3_commit_hook(db_, &Run, this); | |
118 } | |
119 ~ScopedCommitHook() { | |
120 sql::sqlite3_commit_hook(db_, NULL, NULL); | |
121 } | |
122 | |
123 private: | |
124 static int Run(void* p) { | |
125 ScopedCommitHook* t = static_cast<ScopedCommitHook*>(p); | |
126 return t->cb_.Run(); | |
127 } | |
128 | |
129 sqlite3* db_; | |
130 base::Callback<int(void)> cb_; | |
131 | |
132 DISALLOW_COPY_AND_ASSIGN(ScopedCommitHook); | |
133 }; | |
134 | |
135 } // namespace test | |
136 } // namespace sql | |
137 | |
19 namespace { | 138 namespace { |
20 | 139 |
21 // Helper to return the count of items in sqlite_master. Return -1 in | 140 // Helper to return the count of items in sqlite_master. Return -1 in |
22 // case of error. | 141 // case of error. |
23 int SqliteMasterCount(sql::Connection* db) { | 142 int SqliteMasterCount(sql::Connection* db) { |
24 const char* kMasterCount = "SELECT COUNT(*) FROM sqlite_master"; | 143 const char* kMasterCount = "SELECT COUNT(*) FROM sqlite_master"; |
25 sql::Statement s(db->GetUniqueStatement(kMasterCount)); | 144 sql::Statement s(db->GetUniqueStatement(kMasterCount)); |
26 return s.Step() ? s.ColumnInt(0) : -1; | 145 return s.Step() ? s.ColumnInt(0) : -1; |
27 } | 146 } |
28 | 147 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 ~ScopedUmaskSetter() { umask(old_umask_); } | 203 ~ScopedUmaskSetter() { umask(old_umask_); } |
85 private: | 204 private: |
86 mode_t old_umask_; | 205 mode_t old_umask_; |
87 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedUmaskSetter); | 206 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopedUmaskSetter); |
88 }; | 207 }; |
89 #endif | 208 #endif |
90 | 209 |
91 class SQLConnectionTest : public testing::Test { | 210 class SQLConnectionTest : public testing::Test { |
92 public: | 211 public: |
93 void SetUp() override { | 212 void SetUp() override { |
213 // Any macro histograms which fire before the recorder is initialized cannot | |
214 // be tested. So this needs to be ahead of Open(). | |
215 base::StatisticsRecorder::Initialize(); | |
216 | |
94 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 217 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
95 db_path_ = temp_dir_.path().AppendASCII("SQLConnectionTest.db"); | 218 db_path_ = temp_dir_.path().AppendASCII("SQLConnectionTest.db"); |
96 ASSERT_TRUE(db_.Open(db_path_)); | 219 ASSERT_TRUE(db_.Open(db_path_)); |
97 } | 220 } |
98 | 221 |
99 void TearDown() override { db_.Close(); } | 222 void TearDown() override { db_.Close(); } |
100 | 223 |
101 sql::Connection& db() { return db_; } | 224 sql::Connection& db() { return db_; } |
102 const base::FilePath& db_path() { return db_path_; } | 225 const base::FilePath& db_path() { return db_path_; } |
103 | 226 |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
898 EXPECT_TRUE(db().FullIntegrityCheck(&messages)); | 1021 EXPECT_TRUE(db().FullIntegrityCheck(&messages)); |
899 EXPECT_LT(1u, messages.size()); | 1022 EXPECT_LT(1u, messages.size()); |
900 EXPECT_NE(kOk, messages[0]); | 1023 EXPECT_NE(kOk, messages[0]); |
901 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); | 1024 ASSERT_TRUE(ignore_errors.CheckIgnoredErrors()); |
902 } | 1025 } |
903 | 1026 |
904 // TODO(shess): CorruptTableOrIndex could be used to produce a | 1027 // TODO(shess): CorruptTableOrIndex could be used to produce a |
905 // file that would pass the quick check and fail the full check. | 1028 // file that would pass the quick check and fail the full check. |
906 } | 1029 } |
907 | 1030 |
1031 // Test Sqlite.Stats histogram for execute-oriented calls. | |
1032 TEST_F(SQLConnectionTest, EventsExecute) { | |
1033 // Re-open with histogram tag. | |
1034 db().Close(); | |
1035 db().set_histogram_tag("Test"); | |
1036 ASSERT_TRUE(db().Open(db_path())); | |
1037 | |
1038 // Open() uses Execute() extensively, don't track those calls. | |
1039 base::HistogramTester tester; | |
1040 | |
1041 const char kHistogramName[] = "Sqlite.Stats.Test"; | |
1042 const char kGlobalHistogramName[] = "Sqlite.Stats"; | |
1043 | |
1044 ASSERT_TRUE(db().BeginTransaction()); | |
1045 const char* kCreateSql = "CREATE TABLE foo (id INTEGER PRIMARY KEY, value)"; | |
1046 EXPECT_TRUE(db().Execute(kCreateSql)); | |
1047 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (10, 'text')")); | |
1048 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (11, 'text')")); | |
1049 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (12, 'text')")); | |
1050 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (13, 'text')")); | |
1051 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (14, 'text')")); | |
1052 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (15, 'text');" | |
1053 "INSERT INTO foo VALUES (16, 'text');" | |
1054 "INSERT INTO foo VALUES (17, 'text');" | |
1055 "INSERT INTO foo VALUES (18, 'text');" | |
1056 "INSERT INTO foo VALUES (19, 'text')")); | |
1057 ASSERT_TRUE(db().CommitTransaction()); | |
1058 ASSERT_TRUE(db().BeginTransaction()); | |
1059 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (20, 'text')")); | |
1060 db().RollbackTransaction(); | |
1061 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (20, 'text')")); | |
1062 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (21, 'text')")); | |
1063 | |
1064 // The create, 5 inserts, multi-statement insert, rolled-back insert, 2 | |
1065 // inserts outside transaction. | |
1066 tester.ExpectBucketCount(kHistogramName, sql::Connection::EVENT_EXECUTE, 10); | |
1067 tester.ExpectBucketCount(kGlobalHistogramName, | |
1068 sql::Connection::EVENT_EXECUTE, 10); | |
1069 | |
1070 // All of the executes, with the multi-statement inserts broken out, plus one | |
1071 // for each begin, commit, and rollback. | |
1072 tester.ExpectBucketCount(kHistogramName, | |
1073 sql::Connection::EVENT_STATEMENT_RUN, 18); | |
1074 tester.ExpectBucketCount(kGlobalHistogramName, | |
1075 sql::Connection::EVENT_STATEMENT_RUN, 18); | |
1076 | |
1077 tester.ExpectBucketCount(kHistogramName, | |
1078 sql::Connection::EVENT_STATEMENT_ROWS, 0); | |
1079 tester.ExpectBucketCount(kGlobalHistogramName, | |
1080 sql::Connection::EVENT_STATEMENT_ROWS, 0); | |
1081 tester.ExpectBucketCount(kHistogramName, | |
1082 sql::Connection::EVENT_STATEMENT_SUCCESS, 18); | |
1083 tester.ExpectBucketCount(kGlobalHistogramName, | |
1084 sql::Connection::EVENT_STATEMENT_SUCCESS, 18); | |
1085 | |
1086 // The 2 inserts outside the transaction. | |
1087 tester.ExpectBucketCount(kHistogramName, | |
1088 sql::Connection::EVENT_CHANGES_AUTOCOMMIT, 2); | |
1089 tester.ExpectBucketCount(kGlobalHistogramName, | |
1090 sql::Connection::EVENT_CHANGES_AUTOCOMMIT, 2); | |
1091 | |
1092 // 11 inserts inside transactions. | |
1093 tester.ExpectBucketCount(kHistogramName, sql::Connection::EVENT_CHANGES, 11); | |
1094 tester.ExpectBucketCount(kGlobalHistogramName, | |
1095 sql::Connection::EVENT_CHANGES, 11); | |
1096 | |
1097 tester.ExpectBucketCount(kHistogramName, sql::Connection::EVENT_BEGIN, 2); | |
1098 tester.ExpectBucketCount(kGlobalHistogramName, | |
1099 sql::Connection::EVENT_BEGIN, 2); | |
1100 tester.ExpectBucketCount(kHistogramName, sql::Connection::EVENT_COMMIT, 1); | |
1101 tester.ExpectBucketCount(kGlobalHistogramName, | |
1102 sql::Connection::EVENT_COMMIT, 1); | |
1103 tester.ExpectBucketCount(kHistogramName, sql::Connection::EVENT_ROLLBACK, 1); | |
1104 tester.ExpectBucketCount(kGlobalHistogramName, | |
1105 sql::Connection::EVENT_ROLLBACK, 1); | |
1106 } | |
1107 | |
1108 // Test Sqlite.Stats histogram for prepared statements. | |
1109 TEST_F(SQLConnectionTest, EventsStatement) { | |
1110 // Re-open with histogram tag. | |
1111 db().Close(); | |
1112 db().set_histogram_tag("Test"); | |
1113 ASSERT_TRUE(db().Open(db_path())); | |
1114 | |
1115 const char kHistogramName[] = "Sqlite.Stats.Test"; | |
1116 const char kGlobalHistogramName[] = "Sqlite.Stats"; | |
1117 | |
1118 const char* kCreateSql = "CREATE TABLE foo (id INTEGER PRIMARY KEY, value)"; | |
1119 EXPECT_TRUE(db().Execute(kCreateSql)); | |
1120 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (10, 'text')")); | |
1121 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (11, 'text')")); | |
1122 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (12, 'text')")); | |
1123 | |
1124 { | |
1125 base::HistogramTester tester; | |
1126 | |
1127 { | |
1128 sql::Statement s(db().GetUniqueStatement("SELECT value FROM foo")); | |
1129 while (s.Step()) { | |
1130 } | |
1131 } | |
1132 | |
1133 tester.ExpectBucketCount(kHistogramName, | |
1134 sql::Connection::EVENT_STATEMENT_RUN, 1); | |
1135 tester.ExpectBucketCount(kGlobalHistogramName, | |
1136 sql::Connection::EVENT_STATEMENT_RUN, 1); | |
1137 tester.ExpectBucketCount(kHistogramName, | |
1138 sql::Connection::EVENT_STATEMENT_ROWS, 3); | |
1139 tester.ExpectBucketCount(kGlobalHistogramName, | |
1140 sql::Connection::EVENT_STATEMENT_ROWS, 3); | |
1141 tester.ExpectBucketCount(kHistogramName, | |
1142 sql::Connection::EVENT_STATEMENT_SUCCESS, 1); | |
1143 tester.ExpectBucketCount(kGlobalHistogramName, | |
1144 sql::Connection::EVENT_STATEMENT_SUCCESS, 1); | |
1145 } | |
1146 | |
1147 { | |
1148 base::HistogramTester tester; | |
1149 | |
1150 { | |
1151 sql::Statement s(db().GetUniqueStatement( | |
1152 "SELECT value FROM foo WHERE id > 10")); | |
1153 while (s.Step()) { | |
1154 } | |
1155 } | |
1156 | |
1157 tester.ExpectBucketCount(kHistogramName, | |
1158 sql::Connection::EVENT_STATEMENT_RUN, 1); | |
1159 tester.ExpectBucketCount(kGlobalHistogramName, | |
1160 sql::Connection::EVENT_STATEMENT_RUN, 1); | |
1161 tester.ExpectBucketCount(kHistogramName, | |
1162 sql::Connection::EVENT_STATEMENT_ROWS, 2); | |
1163 tester.ExpectBucketCount(kGlobalHistogramName, | |
1164 sql::Connection::EVENT_STATEMENT_ROWS, 2); | |
1165 tester.ExpectBucketCount(kHistogramName, | |
1166 sql::Connection::EVENT_STATEMENT_SUCCESS, 1); | |
1167 tester.ExpectBucketCount(kGlobalHistogramName, | |
1168 sql::Connection::EVENT_STATEMENT_SUCCESS, 1); | |
1169 } | |
1170 } | |
1171 | |
1172 // SQLite function to adjust mock time by |argv[0]| milliseconds. | |
1173 void sqlite_adjust_millis(sql::test::ScopedMockTimeSource* time_mock, | |
1174 sqlite3_context* context, | |
1175 int argc, sqlite3_value** argv) { | |
1176 int64 milliseconds = argc > 0 ? sqlite3_value_int64(argv[0]) : 1000; | |
1177 time_mock->adjust(base::TimeDelta::FromMilliseconds(milliseconds)); | |
1178 sqlite3_result_int64(context, milliseconds); | |
1179 } | |
1180 | |
1181 // Adjust mock time by |milliseconds| on commit. | |
1182 int adjust_commit_hook(sql::test::ScopedMockTimeSource* time_mock, | |
1183 int64 milliseconds) { | |
1184 time_mock->adjust(base::TimeDelta::FromMilliseconds(milliseconds)); | |
1185 return SQLITE_OK; | |
1186 } | |
1187 | |
1188 // Test Sqlite.*Time histograms. | |
1189 TEST_F(SQLConnectionTest, Times) { | |
1190 // Re-open with histogram tag. Use an in-memory database to minimize variance | |
1191 // due to filesystem. | |
1192 db().Close(); | |
1193 db().set_histogram_tag("Test"); | |
1194 ASSERT_TRUE(db().OpenInMemory()); | |
1195 | |
1196 sql::test::ScopedMockTimeSource time_mock(db()); | |
1197 | |
1198 const char kCommitTime[] = "Sqlite.CommitTime.Test"; | |
1199 const char kAutoCommitTime[] = "Sqlite.AutoCommitTime.Test"; | |
1200 const char kUpdateTime[] = "Sqlite.UpdateTime.Test"; | |
1201 const char kQueryTime[] = "Sqlite.QueryTime.Test"; | |
1202 | |
1203 const char* kCreateSql = "CREATE TABLE foo (id INTEGER PRIMARY KEY, value)"; | |
1204 EXPECT_TRUE(db().Execute(kCreateSql)); | |
1205 | |
1206 // Function to inject pauses into statements. | |
1207 sql::test::ScopedScalarFunction scoper( | |
1208 db(), "milliadjust", 1, base::Bind(&sqlite_adjust_millis, &time_mock)); | |
1209 | |
1210 // Read-only query allocates time to query, but not others. | |
1211 { | |
1212 base::HistogramTester tester; | |
1213 | |
1214 EXPECT_TRUE(db().Execute("SELECT milliadjust(10)")); | |
rmcilroy
2015/05/26 10:06:25
nit - I would prefer the each of these tests as se
Scott Hess - ex-Googler
2015/05/29 20:17:08
This seems like a legit request, but wanted to ver
rmcilroy
2015/05/29 20:30:17
I was meaning break out the scoped cases to separa
Scott Hess - ex-Googler
2015/05/29 21:55:09
Yeah, the column-major breakdown turned out to be
| |
1215 | |
1216 scoped_ptr<base::HistogramSamples> samples( | |
1217 tester.GetHistogramSamplesSinceCreation(kQueryTime)); | |
1218 ASSERT_TRUE(samples); | |
1219 // 10 for the adjust, 1 for the measurement. | |
1220 EXPECT_EQ(11, samples->sum()); | |
1221 | |
1222 samples = tester.GetHistogramSamplesSinceCreation(kUpdateTime); | |
1223 EXPECT_TRUE(!samples || samples->sum() == 0); | |
1224 | |
1225 samples = tester.GetHistogramSamplesSinceCreation(kCommitTime); | |
1226 EXPECT_TRUE(!samples || samples->sum() == 0); | |
1227 | |
1228 samples = tester.GetHistogramSamplesSinceCreation(kAutoCommitTime); | |
1229 EXPECT_TRUE(!samples || samples->sum() == 0); | |
1230 } | |
1231 | |
1232 // Autocommit query allocates time to query, update, and autocommit. | |
1233 { | |
1234 base::HistogramTester tester; | |
1235 | |
1236 EXPECT_TRUE(db().Execute("INSERT INTO foo VALUES (10, milliadjust(10))")); | |
1237 | |
1238 scoped_ptr<base::HistogramSamples> samples( | |
1239 tester.GetHistogramSamplesSinceCreation(kQueryTime)); | |
1240 ASSERT_TRUE(samples); | |
1241 // 10 for the adjust, 1 for the measurement. | |
1242 EXPECT_EQ(11, samples->sum()); | |
1243 | |
1244 samples = tester.GetHistogramSamplesSinceCreation(kUpdateTime); | |
1245 ASSERT_TRUE(samples); | |
1246 // 10 for the adjust, 1 for the measurement. | |
1247 EXPECT_EQ(11, samples->sum()); | |
1248 | |
1249 samples = tester.GetHistogramSamplesSinceCreation(kCommitTime); | |
1250 EXPECT_TRUE(!samples || samples->sum() == 0); | |
1251 | |
1252 samples = tester.GetHistogramSamplesSinceCreation(kAutoCommitTime); | |
1253 ASSERT_TRUE(samples); | |
1254 // 10 for the adjust, 1 for the measurement. | |
1255 EXPECT_EQ(11, samples->sum()); | |
1256 } | |
1257 | |
1258 // Explicit transaction allocates query time to query and update, and commit | |
1259 // time to all three. | |
1260 { | |
1261 base::HistogramTester tester; | |
1262 | |
1263 { | |
1264 // Make the commit slow. | |
1265 sql::test::ScopedCommitHook scoped_hook( | |
1266 db(), base::Bind(adjust_commit_hook, &time_mock, 100)); | |
1267 ASSERT_TRUE(db().BeginTransaction()); | |
1268 EXPECT_TRUE(db().Execute( | |
1269 "INSERT INTO foo VALUES (11, milliadjust(10))")); | |
1270 EXPECT_TRUE(db().CommitTransaction()); | |
1271 } | |
1272 | |
1273 scoped_ptr<base::HistogramSamples> samples( | |
1274 tester.GetHistogramSamplesSinceCreation(kQueryTime)); | |
1275 ASSERT_TRUE(samples); | |
1276 // 10 for insert adjust, 100 for commit adjust, 1 for measuring each of | |
1277 // BEGIN, INSERT, and COMMIT. | |
1278 EXPECT_EQ(113, samples->sum()); | |
1279 | |
1280 samples = tester.GetHistogramSamplesSinceCreation(kUpdateTime); | |
1281 ASSERT_TRUE(samples); | |
1282 // 10 for insert adjust, 100 for commit adjust, 1 for measuring each of | |
1283 // INSERT, and COMMIT. | |
1284 EXPECT_EQ(112, samples->sum()); | |
1285 | |
1286 samples = tester.GetHistogramSamplesSinceCreation(kCommitTime); | |
1287 ASSERT_TRUE(samples); | |
1288 // 100 for commit adjust, 1 for measuring COMMIT. | |
1289 EXPECT_EQ(101, samples->sum()); | |
1290 | |
1291 samples = tester.GetHistogramSamplesSinceCreation(kAutoCommitTime); | |
1292 EXPECT_TRUE(!samples || samples->sum() == 0); | |
1293 } | |
1294 } | |
1295 | |
908 } // namespace | 1296 } // namespace |
OLD | NEW |