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

Side by Side Diff: test/unittests/heap/gc-tracer-unittest.cc

Issue 1841043002: Represent speed in GCTracer functions as double instead of int. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 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
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
OLDNEW
« no previous file with comments | « test/unittests/heap/gc-idle-time-handler-unittest.cc ('k') | test/unittests/heap/scavenge-job-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698