OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests of logging functions from log.h | 3 // Tests of logging functions from log.h |
4 | 4 |
5 #ifdef ENABLE_LOGGING_AND_PROFILING | 5 #ifdef ENABLE_LOGGING_AND_PROFILING |
6 | 6 |
7 #include "v8.h" | 7 #include "v8.h" |
8 | 8 |
9 #include "log.h" | 9 #include "log.h" |
10 #include "cctest.h" | 10 #include "cctest.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 buffer[map_log_size] = '\0'; | 159 buffer[map_log_size] = '\0'; |
160 const char* code_creation = "\ncode-creation,"; // eq. to /^code-creation,/ | 160 const char* code_creation = "\ncode-creation,"; // eq. to /^code-creation,/ |
161 CHECK_NE(NULL, strstr(buffer.start(), code_creation)); | 161 CHECK_NE(NULL, strstr(buffer.start(), code_creation)); |
162 | 162 |
163 // Force compiler to generate new code by parametrizing source. | 163 // Force compiler to generate new code by parametrizing source. |
164 EmbeddedVector<char, 100> script_src; | 164 EmbeddedVector<char, 100> script_src; |
165 i::OS::SNPrintF(script_src, | 165 i::OS::SNPrintF(script_src, |
166 "for (var i = 0; i < 1000; ++i) { " | 166 "for (var i = 0; i < 1000; ++i) { " |
167 "(function(x) { return %d * x; })(i); }", | 167 "(function(x) { return %d * x; })(i); }", |
168 log_pos); | 168 log_pos); |
169 // Run code for 200 msecs to get some ticks. Use uint to always have | 169 // Run code for 200 msecs to get some ticks. |
170 // non-negative delta. | 170 const double end_time = i::OS::TimeCurrentMillis() + 200; |
171 const uint64_t started_us = i::OS::Ticks(); | 171 while (i::OS::TimeCurrentMillis() < end_time) { |
172 uint64_t delta; | |
173 while ((delta = i::OS::Ticks() - started_us) < 200 * 1000) { | |
174 CompileAndRunScript(script_src.start()); | 172 CompileAndRunScript(script_src.start()); |
175 } | 173 } |
176 | 174 |
177 Logger::PauseProfiler(); | 175 Logger::PauseProfiler(); |
178 CHECK(!LoggerTestHelper::IsSamplerActive()); | 176 CHECK(!LoggerTestHelper::IsSamplerActive()); |
179 | 177 |
| 178 // Wait 50 msecs to allow Profiler thread to process the last |
| 179 // tick sample it has got. |
| 180 i::OS::Sleep(50); |
| 181 |
180 // Now we must have compiler and tick records. | 182 // Now we must have compiler and tick records. |
181 int log_size = GetLogLines(log_pos, &buffer); | 183 int log_size = GetLogLines(log_pos, &buffer); |
182 printf("log_size: %d\n", log_size); | 184 printf("log_size: %d\n", log_size); |
183 CHECK_GT(log_size, 0); | 185 CHECK_GT(log_size, 0); |
184 CHECK_GT(buffer.length(), log_size); | 186 CHECK_GT(buffer.length(), log_size); |
185 log_pos += log_size; | 187 log_pos += log_size; |
186 // Check buffer contents. | 188 // Check buffer contents. |
187 buffer[log_size] = '\0'; | 189 buffer[log_size] = '\0'; |
188 const char* tick = "\ntick,"; | 190 const char* tick = "\ntick,"; |
189 CHECK_NE(NULL, strstr(buffer.start(), code_creation)); | 191 CHECK_NE(NULL, strstr(buffer.start(), code_creation)); |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 // Make sure that all log data is written prior crash due to CHECK failure. | 703 // Make sure that all log data is written prior crash due to CHECK failure. |
702 fflush(stdout); | 704 fflush(stdout); |
703 CHECK(results_equal); | 705 CHECK(results_equal); |
704 | 706 |
705 env->Exit(); | 707 env->Exit(); |
706 Logger::TearDown(); | 708 Logger::TearDown(); |
707 i::FLAG_always_compact = saved_always_compact; | 709 i::FLAG_always_compact = saved_always_compact; |
708 } | 710 } |
709 | 711 |
710 #endif // ENABLE_LOGGING_AND_PROFILING | 712 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |