OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // | 2 // |
3 // Tests of profiles generator and utilities. | 3 // Tests of profiles generator and utilities. |
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 #include "profile-generator-inl.h" | 8 #include "profile-generator-inl.h" |
9 #include "cctest.h" | 9 #include "cctest.h" |
10 #include "../include/v8-profiler.h" | 10 #include "../include/v8-profiler.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms()); | 646 CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms()); |
647 calc2.UpdateMeasurements(time); | 647 calc2.UpdateMeasurements(time); |
648 CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms()); | 648 CHECK_EQ(kSamplingIntervalMs, calc2.ticks_per_ms()); |
649 time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.5; | 649 time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.5; |
650 calc2.UpdateMeasurements(time); | 650 calc2.UpdateMeasurements(time); |
651 // (1.0 + 2.0) / 2 | 651 // (1.0 + 2.0) / 2 |
652 CHECK_EQ(kSamplingIntervalMs * 1.5, calc2.ticks_per_ms()); | 652 CHECK_EQ(kSamplingIntervalMs * 1.5, calc2.ticks_per_ms()); |
653 time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.75; | 653 time += SampleRateCalculator::kWallTimeQueryIntervalMs * 0.75; |
654 calc2.UpdateMeasurements(time); | 654 calc2.UpdateMeasurements(time); |
655 // (1.0 + 2.0 + 2.0) / 3 | 655 // (1.0 + 2.0 + 2.0) / 3 |
656 CHECK_EQ(kSamplingIntervalMs * 1.66666, calc2.ticks_per_ms()); | 656 CHECK_EQ(kSamplingIntervalMs * 5.0, round(calc2.ticks_per_ms() * 3.0)); |
657 | 657 |
658 SampleRateCalculator calc3; | 658 SampleRateCalculator calc3; |
659 time = 0.0; | 659 time = 0.0; |
660 CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms()); | 660 CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms()); |
661 calc3.UpdateMeasurements(time); | 661 calc3.UpdateMeasurements(time); |
662 CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms()); | 662 CHECK_EQ(kSamplingIntervalMs, calc3.ticks_per_ms()); |
663 time += SampleRateCalculator::kWallTimeQueryIntervalMs * 2; | 663 time += SampleRateCalculator::kWallTimeQueryIntervalMs * 2; |
664 calc3.UpdateMeasurements(time); | 664 calc3.UpdateMeasurements(time); |
665 // (1.0 + 0.5) / 2 | 665 // (1.0 + 0.5) / 2 |
666 CHECK_EQ(kSamplingIntervalMs * 0.75, calc3.ticks_per_ms()); | 666 CHECK_EQ(kSamplingIntervalMs * 0.75, calc3.ticks_per_ms()); |
667 time += SampleRateCalculator::kWallTimeQueryIntervalMs * 1.5; | 667 time += SampleRateCalculator::kWallTimeQueryIntervalMs * 1.5; |
668 calc3.UpdateMeasurements(time); | 668 calc3.UpdateMeasurements(time); |
669 // (1.0 + 0.5 + 0.5) / 3 | 669 // (1.0 + 0.5 + 0.5) / 3 |
670 CHECK_EQ(kSamplingIntervalMs * 0.66666, calc3.ticks_per_ms()); | 670 CHECK_EQ(kSamplingIntervalMs * 2.0, round(calc3.ticks_per_ms() * 3.0)); |
671 } | 671 } |
672 | 672 |
673 | 673 |
674 // --- P r o f i l e r E x t e n s i o n --- | 674 // --- P r o f i l e r E x t e n s i o n --- |
675 | 675 |
676 class ProfilerExtension : public v8::Extension { | 676 class ProfilerExtension : public v8::Extension { |
677 public: | 677 public: |
678 ProfilerExtension() : v8::Extension("v8/profiler", kSource) { } | 678 ProfilerExtension() : v8::Extension("v8/profiler", kSource) { } |
679 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( | 679 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( |
680 v8::Handle<v8::String> name); | 680 v8::Handle<v8::String> name); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 current = PickChild(current, "a"); | 769 current = PickChild(current, "a"); |
770 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 770 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
771 current = PickChild(current, "b"); | 771 current = PickChild(current, "b"); |
772 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 772 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
773 current = PickChild(current, "c"); | 773 current = PickChild(current, "c"); |
774 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); | 774 CHECK_NE(NULL, const_cast<ProfileNode*>(current)); |
775 CHECK_EQ(0, current->children()->length()); | 775 CHECK_EQ(0, current->children()->length()); |
776 } | 776 } |
777 | 777 |
778 #endif // ENABLE_LOGGING_AND_PROFILING | 778 #endif // ENABLE_LOGGING_AND_PROFILING |
OLD | NEW |