Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: net/udp/udp_socket_perftest.cc

Issue 1349783006: Cleanup: Pass std::string as const reference if possible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert third_party changes Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/perf_time_logger.h" 10 #include "base/test/perf_time_logger.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // has effect on Windows. 45 // has effect on Windows.
46 void WriteBenchmark(bool use_nonblocking_io); 46 void WriteBenchmark(bool use_nonblocking_io);
47 47
48 protected: 48 protected:
49 static const int kPacketSize = 1024; 49 static const int kPacketSize = 1024;
50 scoped_refptr<IOBufferWithSize> buffer_; 50 scoped_refptr<IOBufferWithSize> buffer_;
51 base::WeakPtrFactory<UDPSocketPerfTest> weak_factory_; 51 base::WeakPtrFactory<UDPSocketPerfTest> weak_factory_;
52 }; 52 };
53 53
54 // Creates and address from an ip/port and returns it in |address|. 54 // Creates and address from an ip/port and returns it in |address|.
55 void CreateUDPAddress(std::string ip_str, uint16 port, IPEndPoint* address) { 55 void CreateUDPAddress(const std::string& ip_str,
56 uint16 port,
57 IPEndPoint* address) {
56 IPAddressNumber ip_number; 58 IPAddressNumber ip_number;
57 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number); 59 bool rv = ParseIPLiteralToNumber(ip_str, &ip_number);
58 if (!rv) 60 if (!rv)
59 return; 61 return;
60 *address = IPEndPoint(ip_number, port); 62 *address = IPEndPoint(ip_number, port);
61 } 63 }
62 64
63 void UDPSocketPerfTest::WritePacketsToSocket(UDPClientSocket* socket, 65 void UDPSocketPerfTest::WritePacketsToSocket(UDPClientSocket* socket,
64 int num_of_packets, 66 int num_of_packets,
65 base::Closure done_callback) { 67 base::Closure done_callback) {
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 #if defined(OS_WIN) 132 #if defined(OS_WIN)
131 TEST_F(UDPSocketPerfTest, WriteNonBlocking) { 133 TEST_F(UDPSocketPerfTest, WriteNonBlocking) {
132 base::PerfTimeLogger timer("UDP_socket_write_nonblocking"); 134 base::PerfTimeLogger timer("UDP_socket_write_nonblocking");
133 WriteBenchmark(true); 135 WriteBenchmark(true);
134 } 136 }
135 #endif 137 #endif
136 138
137 } // namespace 139 } // namespace
138 140
139 } // namespace net 141 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698