OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project 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 <cmath> | 5 #include <cmath> |
6 #include <limits> | 6 #include <limits> |
7 | 7 |
8 #include "src/globals.h" | 8 #include "src/globals.h" |
9 #include "src/heap/gc-tracer.h" | 9 #include "src/heap/gc-tracer.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
11 #include "test/unittests/test-utils.h" | 11 #include "test/unittests/test-utils.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 typedef TestWithContext GCTracerTest; | 17 typedef TestWithContext GCTracerTest; |
18 | 18 |
19 TEST(GCTracer, AverageSpeed) { | 19 TEST(GCTracer, AverageSpeed) { |
20 RingBuffer<BytesAndDuration> buffer; | 20 base::RingBuffer<BytesAndDuration> buffer; |
21 EXPECT_EQ(100 / 2, | 21 EXPECT_EQ(100 / 2, |
22 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(100, 2), 0)); | 22 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(100, 2), 0)); |
23 buffer.Push(MakeBytesAndDuration(100, 8)); | 23 buffer.Push(MakeBytesAndDuration(100, 8)); |
24 EXPECT_EQ(100 / 2, | 24 EXPECT_EQ(100 / 2, |
25 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(100, 2), 2)); | 25 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(100, 2), 2)); |
26 EXPECT_EQ(200 / 10, | 26 EXPECT_EQ(200 / 10, |
27 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(100, 2), 3)); | 27 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(100, 2), 3)); |
28 const int max_speed = 1024 * MB; | 28 const int max_speed = 1024 * MB; |
29 buffer.Reset(); | 29 buffer.Reset(); |
30 buffer.Push(MakeBytesAndDuration(max_speed, 0.5)); | 30 buffer.Push(MakeBytesAndDuration(max_speed, 0.5)); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // Switch to incremental MC. | 289 // Switch to incremental MC. |
290 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR; | 290 tracer->current_.type = GCTracer::Event::INCREMENTAL_MARK_COMPACTOR; |
291 tracer->Stop(MARK_COMPACTOR); | 291 tracer->Stop(MARK_COMPACTOR); |
292 EXPECT_DOUBLE_EQ((4000000.0 / 400 + 1000.0 / 2000) / 2, | 292 EXPECT_DOUBLE_EQ((4000000.0 / 400 + 1000.0 / 2000) / 2, |
293 static_cast<double>( | 293 static_cast<double>( |
294 tracer->IncrementalMarkingSpeedInBytesPerMillisecond())); | 294 tracer->IncrementalMarkingSpeedInBytesPerMillisecond())); |
295 } | 295 } |
296 | 296 |
297 } // namespace internal | 297 } // namespace internal |
298 } // namespace v8 | 298 } // namespace v8 |
OLD | NEW |