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

Unified Diff: runtime/vm/thread_interrupter_test.cc

Issue 1412733008: Switch profiler from isolates to threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/thread_interrupter_test.cc
diff --git a/runtime/vm/thread_interrupter_test.cc b/runtime/vm/thread_interrupter_test.cc
index aeb9ff188f8d7c79bc106dc5d2430cc6def59247..24af454200198ff152cdbc88d3dd7b6708a2b1f2 100644
--- a/runtime/vm/thread_interrupter_test.cc
+++ b/runtime/vm/thread_interrupter_test.cc
@@ -16,30 +16,32 @@ class ThreadInterrupterTestHelper : public AllStatic {
public:
static void InterruptTest(const intptr_t run_time, const intptr_t period) {
const double allowed_error = 0.25; // +/- 25%
- intptr_t count = 0;
+ counter = 0;
Thread::EnsureInit();
Thread* thread = Thread::Current();
- thread->SetThreadInterrupter(IncrementCallback, &count);
+ thread->SetThreadInterruptCallback(IncrementCallback);
ThreadInterrupter::SetInterruptPeriod(period);
OS::Sleep(run_time * kMillisecondsPerSecond);
- thread->SetThreadInterrupter(NULL, NULL);
+ thread->SetThreadInterruptCallback(NULL);
intptr_t run_time_micros = run_time * kMicrosecondsPerSecond;
intptr_t expected_interrupts = run_time_micros / period;
intptr_t error = allowed_error * expected_interrupts;
intptr_t low_bar = expected_interrupts - error;
intptr_t high_bar = expected_interrupts + error;
- EXPECT_GE(count, low_bar);
- EXPECT_LE(count, high_bar);
+ EXPECT_GE(counter, low_bar);
+ EXPECT_LE(counter, high_bar);
}
- static void IncrementCallback(const InterruptedThreadState& state,
- void* data) {
- ASSERT(data != NULL);
- intptr_t* counter = reinterpret_cast<intptr_t*>(data);
- *counter = *counter + 1;
+ static intptr_t counter;
+
+ static void IncrementCallback(Thread* thread,
+ const InterruptedThreadState& state) {
+ ASSERT(thread != NULL);
+ counter++;
}
};
+intptr_t ThreadInterrupterTestHelper::counter = 0;
TEST_CASE(ThreadInterrupterHigh) {
const intptr_t kRunTimeSeconds = 5;

Powered by Google App Engine
This is Rietveld 408576698