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

Side by Side Diff: test/cctest/test-log.cc

Issue 1118533003: Make CPU profiler do not hog 100% of CPU. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: still uploading Created 5 years, 7 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 | « test/cctest/test-cpu-profiler.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 v8::HandleScope scope; 183 v8::HandleScope scope;
184 v8::Persistent<v8::Context> context = v8::Context::New(); 184 v8::Persistent<v8::Context> context = v8::Context::New();
185 CHECK(!context.IsEmpty()); 185 CHECK(!context.IsEmpty());
186 { 186 {
187 v8::Context::Scope context_scope(context); 187 v8::Context::Scope context_scope(context);
188 SignalRunning(); 188 SignalRunning();
189 CompileRun( 189 CompileRun(
190 "var j; for (var i=0; i<10000; ++i) { j = Math.sin(i); }"); 190 "var j; for (var i=0; i<10000; ++i) { j = Math.sin(i); }");
191 } 191 }
192 context.Dispose(); 192 context.Dispose();
193 i::OS::Sleep(1); 193 i::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(1));
194 } 194 }
195 } 195 }
196 }; 196 };
197 197
198 198
199 class LoopingNonJsThread : public LoopingThread { 199 class LoopingNonJsThread : public LoopingThread {
200 public: 200 public:
201 explicit LoopingNonJsThread(v8::internal::Isolate* isolate) 201 explicit LoopingNonJsThread(v8::internal::Isolate* isolate)
202 : LoopingThread(isolate) { } 202 : LoopingThread(isolate) { }
203 void RunLoop() { 203 void RunLoop() {
204 v8::Locker locker; 204 v8::Locker locker;
205 v8::Unlocker unlocker; 205 v8::Unlocker unlocker;
206 // Now thread has V8's id, but will not run VM code. 206 // Now thread has V8's id, but will not run VM code.
207 CHECK(CcTest::i_isolate() != NULL); 207 CHECK(CcTest::i_isolate() != NULL);
208 CHECK_GT(CcTest::i_isolate()->thread_manager()->CurrentId(), 0); 208 CHECK_GT(CcTest::i_isolate()->thread_manager()->CurrentId(), 0);
209 double i = 10; 209 double i = 10;
210 SignalRunning(); 210 SignalRunning();
211 while (IsRunning()) { 211 while (IsRunning()) {
212 i = std::sin(i); 212 i = std::sin(i);
213 i::OS::Sleep(1); 213 i::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(1));
214 } 214 }
215 } 215 }
216 }; 216 };
217 217
218 218
219 class TestSampler : public v8::internal::Sampler { 219 class TestSampler : public v8::internal::Sampler {
220 public: 220 public:
221 explicit TestSampler(v8::internal::Isolate* isolate) 221 explicit TestSampler(v8::internal::Isolate* isolate)
222 : Sampler(isolate, 0, true, true), 222 : Sampler(isolate, 0, true, true),
223 semaphore_(new v8::internal::Semaphore(0)), 223 semaphore_(new v8::internal::Semaphore(0)),
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 CHECK(exists); 524 CHECK(exists);
525 i::EmbeddedVector<char, 100> ref_data; 525 i::EmbeddedVector<char, 100> ref_data;
526 i::SNPrintF(ref_data, "v8-version,%d,%d,%d,%d,%d", i::Version::GetMajor(), 526 i::SNPrintF(ref_data, "v8-version,%d,%d,%d,%d,%d", i::Version::GetMajor(),
527 i::Version::GetMinor(), i::Version::GetBuild(), 527 i::Version::GetMinor(), i::Version::GetBuild(),
528 i::Version::GetPatch(), i::Version::IsCandidate()); 528 i::Version::GetPatch(), i::Version::IsCandidate());
529 CHECK(StrNStr(log.start(), ref_data.start(), log.length())); 529 CHECK(StrNStr(log.start(), ref_data.start(), log.length()));
530 log.Dispose(); 530 log.Dispose();
531 } 531 }
532 isolate->Dispose(); 532 isolate->Dispose();
533 } 533 }
OLDNEW
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698