| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/memory/weak_ptr.h" | 6 #include "base/memory/weak_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/perf_time_logger.h" | 9 #include "base/test/perf_time_logger.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 void UDPSocketPerfTest::WriteBenchmark(bool use_nonblocking_io) { | 84 void UDPSocketPerfTest::WriteBenchmark(bool use_nonblocking_io) { |
| 85 base::MessageLoopForIO message_loop; | 85 base::MessageLoopForIO message_loop; |
| 86 const uint16_t kPort = 9999; | 86 const uint16_t kPort = 9999; |
| 87 | 87 |
| 88 // Setup the server to listen. | 88 // Setup the server to listen. |
| 89 IPEndPoint bind_address; | 89 IPEndPoint bind_address; |
| 90 CreateUDPAddress("127.0.0.1", kPort, &bind_address); | 90 CreateUDPAddress("127.0.0.1", kPort, &bind_address); |
| 91 scoped_ptr<UDPServerSocket> server( | 91 std::unique_ptr<UDPServerSocket> server( |
| 92 new UDPServerSocket(nullptr, NetLog::Source())); | 92 new UDPServerSocket(nullptr, NetLog::Source())); |
| 93 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
| 94 if (use_nonblocking_io) | 94 if (use_nonblocking_io) |
| 95 server->UseNonBlockingIO(); | 95 server->UseNonBlockingIO(); |
| 96 #endif | 96 #endif |
| 97 int rv = server->Listen(bind_address); | 97 int rv = server->Listen(bind_address); |
| 98 ASSERT_EQ(OK, rv); | 98 ASSERT_EQ(OK, rv); |
| 99 | 99 |
| 100 // Setup the client. | 100 // Setup the client. |
| 101 IPEndPoint server_address; | 101 IPEndPoint server_address; |
| 102 CreateUDPAddress("127.0.0.1", kPort, &server_address); | 102 CreateUDPAddress("127.0.0.1", kPort, &server_address); |
| 103 scoped_ptr<UDPClientSocket> client( | 103 std::unique_ptr<UDPClientSocket> client( |
| 104 new UDPClientSocket(DatagramSocket::DEFAULT_BIND, RandIntCallback(), | 104 new UDPClientSocket(DatagramSocket::DEFAULT_BIND, RandIntCallback(), |
| 105 nullptr, NetLog::Source())); | 105 nullptr, NetLog::Source())); |
| 106 #if defined(OS_WIN) | 106 #if defined(OS_WIN) |
| 107 if (use_nonblocking_io) | 107 if (use_nonblocking_io) |
| 108 client->UseNonBlockingIO(); | 108 client->UseNonBlockingIO(); |
| 109 #endif | 109 #endif |
| 110 rv = client->Connect(server_address); | 110 rv = client->Connect(server_address); |
| 111 EXPECT_EQ(OK, rv); | 111 EXPECT_EQ(OK, rv); |
| 112 | 112 |
| 113 base::RunLoop run_loop; | 113 base::RunLoop run_loop; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 129 #if defined(OS_WIN) | 129 #if defined(OS_WIN) |
| 130 TEST_F(UDPSocketPerfTest, WriteNonBlocking) { | 130 TEST_F(UDPSocketPerfTest, WriteNonBlocking) { |
| 131 base::PerfTimeLogger timer("UDP_socket_write_nonblocking"); | 131 base::PerfTimeLogger timer("UDP_socket_write_nonblocking"); |
| 132 WriteBenchmark(true); | 132 WriteBenchmark(true); |
| 133 } | 133 } |
| 134 #endif | 134 #endif |
| 135 | 135 |
| 136 } // namespace | 136 } // namespace |
| 137 | 137 |
| 138 } // namespace net | 138 } // namespace net |
| OLD | NEW |