OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <errno.h> | 5 #include <errno.h> |
6 #include <fcntl.h> | 6 #include <fcntl.h> |
7 #include <linux/if_tun.h> | 7 #include <linux/if_tun.h> |
8 #include <linux/types.h> | 8 #include <linux/types.h> |
9 #include <math.h> | 9 #include <math.h> |
10 #include <net/if.h> | 10 #include <net/if.h> |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 double megabits_per_second() { | 144 double megabits_per_second() { |
145 double megabits = (byte_data_.back() - byte_data_.front()) * 8 / 1E6; | 145 double megabits = (byte_data_.back() - byte_data_.front()) * 8 / 1E6; |
146 return megabits / time_range().InSecondsF(); | 146 return megabits / time_range().InSecondsF(); |
147 } | 147 } |
148 | 148 |
149 double packets_per_second() { | 149 double packets_per_second() { |
150 double packets = packet_data_.back()- packet_data_.front(); | 150 double packets = packet_data_.back()- packet_data_.front(); |
151 return packets / time_range().InSecondsF(); | 151 return packets / time_range().InSecondsF(); |
152 } | 152 } |
153 | 153 |
154 void Increment(uint64 x) { | 154 void Increment(uint64_t x) { |
155 bytes_ += x; | 155 bytes_ += x; |
156 packets_ ++; | 156 packets_ ++; |
157 } | 157 } |
158 | 158 |
159 private: | 159 private: |
160 uint64 bytes_; | 160 uint64_t bytes_; |
161 uint64 packets_; | 161 uint64_t packets_; |
162 std::deque<uint64> byte_data_; | 162 std::deque<uint64_t> byte_data_; |
163 std::deque<uint64> packet_data_; | 163 std::deque<uint64_t> packet_data_; |
164 std::deque<base::TimeTicks> time_data_; | 164 std::deque<base::TimeTicks> time_data_; |
165 }; | 165 }; |
166 | 166 |
167 ByteCounter in_pipe_input_counter; | 167 ByteCounter in_pipe_input_counter; |
168 ByteCounter in_pipe_output_counter; | 168 ByteCounter in_pipe_output_counter; |
169 ByteCounter out_pipe_input_counter; | 169 ByteCounter out_pipe_input_counter; |
170 ByteCounter out_pipe_output_counter; | 170 ByteCounter out_pipe_output_counter; |
171 | 171 |
172 class ByteCounterPipe : public media::cast::test::PacketPipe { | 172 class ByteCounterPipe : public media::cast::test::PacketPipe { |
173 public: | 173 public: |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 int fd2 = tun_alloc(argv[2], IFF_TAP); | 308 int fd2 = tun_alloc(argv[2], IFF_TAP); |
309 | 309 |
310 base::MessageLoopForIO message_loop; | 310 base::MessageLoopForIO message_loop; |
311 last_printout = base::TimeTicks::Now(); | 311 last_printout = base::TimeTicks::Now(); |
312 media::cast::test::QueueManager qm1(fd1, fd2, in_pipe.Pass()); | 312 media::cast::test::QueueManager qm1(fd1, fd2, in_pipe.Pass()); |
313 media::cast::test::QueueManager qm2(fd2, fd1, out_pipe.Pass()); | 313 media::cast::test::QueueManager qm2(fd2, fd1, out_pipe.Pass()); |
314 CheckByteCounters(); | 314 CheckByteCounters(); |
315 printf("Press Ctrl-C when done.\n"); | 315 printf("Press Ctrl-C when done.\n"); |
316 message_loop.Run(); | 316 message_loop.Run(); |
317 } | 317 } |
OLD | NEW |