| 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 |
| 11 #include "webrtc/rtc_base/fileutils.h" | 11 #include "webrtc/rtc_base/fileutils.h" |
| 12 #include "webrtc/rtc_base/gunit.h" | 12 #include "webrtc/rtc_base/gunit.h" |
| 13 #include "webrtc/rtc_base/logging.h" | 13 #include "webrtc/rtc_base/logging.h" |
| 14 #include "webrtc/rtc_base/nullsocketserver.h" | 14 #include "webrtc/rtc_base/nullsocketserver.h" |
| 15 #include "webrtc/rtc_base/pathutils.h" | |
| 16 #include "webrtc/rtc_base/stream.h" | 15 #include "webrtc/rtc_base/stream.h" |
| 17 #include "webrtc/rtc_base/thread.h" | 16 #include "webrtc/rtc_base/thread.h" |
| 17 #include "webrtc/test/testsupport/fileutils.h" |
| 18 | 18 |
| 19 namespace rtc { | 19 namespace rtc { |
| 20 | 20 |
| 21 template <typename Base> | 21 template <typename Base> |
| 22 class LogSinkImpl | 22 class LogSinkImpl |
| 23 : public LogSink, | 23 : public LogSink, |
| 24 public Base { | 24 public Base { |
| 25 public: | 25 public: |
| 26 LogSinkImpl() {} | 26 LogSinkImpl() {} |
| 27 | 27 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 132 |
| 133 // Test the time required to write 1000 80-character logs to an unbuffered file. | 133 // Test the time required to write 1000 80-character logs to an unbuffered file. |
| 134 #if defined (WEBRTC_ANDROID) | 134 #if defined (WEBRTC_ANDROID) |
| 135 // Fails on Android: https://bugs.chromium.org/p/webrtc/issues/detail?id=4364. | 135 // Fails on Android: https://bugs.chromium.org/p/webrtc/issues/detail?id=4364. |
| 136 #define MAYBE_Perf DISABLED_Perf | 136 #define MAYBE_Perf DISABLED_Perf |
| 137 #else | 137 #else |
| 138 #define MAYBE_Perf Perf | 138 #define MAYBE_Perf Perf |
| 139 #endif | 139 #endif |
| 140 | 140 |
| 141 TEST(LogTest, MAYBE_Perf) { | 141 TEST(LogTest, MAYBE_Perf) { |
| 142 Pathname path; | 142 std::string path = |
| 143 EXPECT_TRUE(Filesystem::GetTemporaryFolder(path, true, nullptr)); | 143 webrtc::test::TempFilename(webrtc::test::OutputPath(), "ut"); |
| 144 path.SetPathname(Filesystem::TempFilename(path, "ut")); | |
| 145 | 144 |
| 146 LogSinkImpl<FileStream> stream; | 145 LogSinkImpl<FileStream> stream; |
| 147 EXPECT_TRUE(stream.Open(path.pathname(), "wb", nullptr)); | 146 EXPECT_TRUE(stream.Open(path, "wb", nullptr)); |
| 148 stream.DisableBuffering(); | 147 stream.DisableBuffering(); |
| 149 LogMessage::AddLogToStream(&stream, LS_SENSITIVE); | 148 LogMessage::AddLogToStream(&stream, LS_SENSITIVE); |
| 150 | 149 |
| 151 int64_t start = TimeMillis(), finish; | 150 int64_t start = TimeMillis(), finish; |
| 152 std::string message('X', 80); | 151 std::string message('X', 80); |
| 153 for (int i = 0; i < 1000; ++i) { | 152 for (int i = 0; i < 1000; ++i) { |
| 154 LOG(LS_SENSITIVE) << message; | 153 LOG(LS_SENSITIVE) << message; |
| 155 } | 154 } |
| 156 finish = TimeMillis(); | 155 finish = TimeMillis(); |
| 157 | 156 |
| 158 LogMessage::RemoveLogToStream(&stream); | 157 LogMessage::RemoveLogToStream(&stream); |
| 159 stream.Close(); | 158 stream.Close(); |
| 160 Filesystem::DeleteFile(path); | 159 webrtc::test::RemoveFile(path); |
| 161 | 160 |
| 162 LOG(LS_INFO) << "Average log time: " << TimeDiff(finish, start) << " ms"; | 161 LOG(LS_INFO) << "Average log time: " << TimeDiff(finish, start) << " ms"; |
| 163 } | 162 } |
| 164 | 163 |
| 165 } // namespace rtc | 164 } // namespace rtc |
| OLD | NEW |