OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 LogMessage::RemoveLogToStream(&stream1); | 116 LogMessage::RemoveLogToStream(&stream1); |
117 LogMessage::RemoveLogToStream(&stream2); | 117 LogMessage::RemoveLogToStream(&stream2); |
118 LogMessage::RemoveLogToStream(&stream3); | 118 LogMessage::RemoveLogToStream(&stream3); |
119 } | 119 } |
120 | 120 |
121 EXPECT_EQ(sev, LogMessage::GetLogToStream(NULL)); | 121 EXPECT_EQ(sev, LogMessage::GetLogToStream(NULL)); |
122 } | 122 } |
123 | 123 |
124 | 124 |
125 TEST(LogTest, WallClockStartTime) { | 125 TEST(LogTest, WallClockStartTime) { |
126 uint32 time = LogMessage::WallClockStartTime(); | 126 uint32_t time = LogMessage::WallClockStartTime(); |
127 // Expect the time to be in a sensible range, e.g. > 2012-01-01. | 127 // Expect the time to be in a sensible range, e.g. > 2012-01-01. |
128 EXPECT_GT(time, 1325376000u); | 128 EXPECT_GT(time, 1325376000u); |
129 } | 129 } |
130 | 130 |
131 // Test the time required to write 1000 80-character logs to an unbuffered file. | 131 // Test the time required to write 1000 80-character logs to an unbuffered file. |
132 TEST(LogTest, Perf) { | 132 TEST(LogTest, Perf) { |
133 Pathname path; | 133 Pathname path; |
134 EXPECT_TRUE(Filesystem::GetTemporaryFolder(path, true, NULL)); | 134 EXPECT_TRUE(Filesystem::GetTemporaryFolder(path, true, NULL)); |
135 path.SetPathname(Filesystem::TempFilename(path, "ut")); | 135 path.SetPathname(Filesystem::TempFilename(path, "ut")); |
136 | 136 |
137 LogSinkImpl<FileStream> stream; | 137 LogSinkImpl<FileStream> stream; |
138 EXPECT_TRUE(stream.Open(path.pathname(), "wb", NULL)); | 138 EXPECT_TRUE(stream.Open(path.pathname(), "wb", NULL)); |
139 stream.DisableBuffering(); | 139 stream.DisableBuffering(); |
140 LogMessage::AddLogToStream(&stream, LS_SENSITIVE); | 140 LogMessage::AddLogToStream(&stream, LS_SENSITIVE); |
141 | 141 |
142 uint32 start = Time(), finish; | 142 uint32_t start = Time(), finish; |
143 std::string message('X', 80); | 143 std::string message('X', 80); |
144 for (int i = 0; i < 1000; ++i) { | 144 for (int i = 0; i < 1000; ++i) { |
145 LOG(LS_SENSITIVE) << message; | 145 LOG(LS_SENSITIVE) << message; |
146 } | 146 } |
147 finish = Time(); | 147 finish = Time(); |
148 | 148 |
149 LogMessage::RemoveLogToStream(&stream); | 149 LogMessage::RemoveLogToStream(&stream); |
150 stream.Close(); | 150 stream.Close(); |
151 Filesystem::DeleteFile(path); | 151 Filesystem::DeleteFile(path); |
152 | 152 |
153 LOG(LS_INFO) << "Average log time: " << TimeDiff(finish, start) << " us"; | 153 LOG(LS_INFO) << "Average log time: " << TimeDiff(finish, start) << " us"; |
154 } | 154 } |
155 | 155 |
156 } // namespace rtc | 156 } // namespace rtc |
OLD | NEW |