| 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/heap/gc-tracer.h" | 8 #include "src/heap/gc-tracer.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 buffer.Push(MakeBytesAndDuration(1, 10000)); | 30 buffer.Push(MakeBytesAndDuration(1, 10000)); |
| 31 EXPECT_EQ(min_speed, | 31 EXPECT_EQ(min_speed, |
| 32 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(0, 0), 1)); | 32 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(0, 0), 1)); |
| 33 buffer.Reset(); | 33 buffer.Reset(); |
| 34 int sum = 0; | 34 int sum = 0; |
| 35 for (int i = 0; i < buffer.kSize; i++) { | 35 for (int i = 0; i < buffer.kSize; i++) { |
| 36 sum += i + 1; | 36 sum += i + 1; |
| 37 buffer.Push(MakeBytesAndDuration(i + 1, 1)); | 37 buffer.Push(MakeBytesAndDuration(i + 1, 1)); |
| 38 } | 38 } |
| 39 EXPECT_EQ( | 39 EXPECT_EQ( |
| 40 static_cast<int>(sum * 1.0 / buffer.kSize + 0.5), | 40 sum * 1.0 / buffer.kSize, |
| 41 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(0, 0), buffer.kSize)); | 41 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(0, 0), buffer.kSize)); |
| 42 buffer.Push(MakeBytesAndDuration(100, 1)); | 42 buffer.Push(MakeBytesAndDuration(100, 1)); |
| 43 EXPECT_EQ( | 43 EXPECT_EQ( |
| 44 static_cast<int>((sum * 1.0 - 1 + 100) / buffer.kSize + 0.5), | 44 (sum * 1.0 - 1 + 100) / buffer.kSize, |
| 45 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(0, 0), buffer.kSize)); | 45 GCTracer::AverageSpeed(buffer, MakeBytesAndDuration(0, 0), buffer.kSize)); |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace internal | 48 } // namespace internal |
| 49 } // namespace v8 | 49 } // namespace v8 |
| OLD | NEW |