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

Side by Side Diff: ui/gl/gpu_timing_unittest.cc

Issue 1647333002: Fix GPUTiming offset so it is stable within significant digits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Increased fake CPU time in unittest to be greater than 1ms Created 4 years, 10 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
« no previous file with comments | « ui/gl/gpu_timing.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gl/gl_context_stub_with_extensions.h" 10 #include "ui/gl/gl_context_stub_with_extensions.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 scoped_refptr<GPUTimingClient> client2 = CreateGPUTimingClient(); 100 scoped_refptr<GPUTimingClient> client2 = CreateGPUTimingClient();
101 EXPECT_TRUE(client2->IsForceTimeElapsedQuery()); 101 EXPECT_TRUE(client2->IsForceTimeElapsedQuery());
102 } 102 }
103 103
104 TEST_F(GPUTimingTest, QueryTimeStampTest) { 104 TEST_F(GPUTimingTest, QueryTimeStampTest) {
105 SetupGLContext("3.2", "GL_ARB_timer_query"); 105 SetupGLContext("3.2", "GL_ARB_timer_query");
106 scoped_refptr<GPUTimingClient> client = CreateGPUTimingClient(); 106 scoped_refptr<GPUTimingClient> client = CreateGPUTimingClient();
107 scoped_ptr<GPUTimer> gpu_timer = client->CreateGPUTimer(false); 107 scoped_ptr<GPUTimer> gpu_timer = client->CreateGPUTimer(false);
108 108
109 const int64_t begin_cpu_time = 123; 109 const int64_t begin_cpu_time = 1230;
110 const int64_t begin_gl_time = 10 * base::Time::kNanosecondsPerMicrosecond; 110 const int64_t begin_gl_time = 10 * base::Time::kNanosecondsPerMicrosecond;
111 const int64_t cpu_gl_offset = 111 const int64_t cpu_gl_offset =
112 begin_gl_time / base::Time::kNanosecondsPerMicrosecond - begin_cpu_time; 112 begin_gl_time / base::Time::kNanosecondsPerMicrosecond - begin_cpu_time;
113 gpu_timing_fake_queries_.SetCPUGLOffset(cpu_gl_offset); 113 gpu_timing_fake_queries_.SetCPUGLOffset(cpu_gl_offset);
114 gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time); 114 gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time);
115 gpu_timing_fake_queries_.ExpectGPUTimeStampQuery(*gl_, false); 115 gpu_timing_fake_queries_.ExpectGPUTimeStampQuery(*gl_, false);
116 116
117 gpu_timer->QueryTimeStamp(); 117 gpu_timer->QueryTimeStamp();
118 118
119 gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time - 1); 119 gpu_timing_fake_queries_.SetCurrentCPUTime(begin_cpu_time - 1);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 EXPECT_TRUE(gpu_timer->IsAvailable()); 157 EXPECT_TRUE(gpu_timer->IsAvailable());
158 EXPECT_EQ(0, gpu_timer->GetDeltaElapsed()); 158 EXPECT_EQ(0, gpu_timer->GetDeltaElapsed());
159 159
160 int64_t start, end; 160 int64_t start, end;
161 gpu_timer->GetStartEndTimestamps(&start, &end); 161 gpu_timer->GetStartEndTimestamps(&start, &end);
162 EXPECT_EQ(begin_cpu_time, start); 162 EXPECT_EQ(begin_cpu_time, start);
163 EXPECT_EQ(begin_cpu_time, end); 163 EXPECT_EQ(begin_cpu_time, end);
164 } 164 }
165 165
166 } // namespace gpu 166 } // namespace gpu
OLDNEW
« no previous file with comments | « ui/gl/gpu_timing.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698