CpuProfilerStage extends StreamingStage implements CodeNavigator.Listener { @NotNull public CpuProfilerConfigModel getProfilerConfigModel() { return myProfilerConfigModel; } CpuProfilerStage(@NotNull StudioProfilers profilers);  CpuProfilerStage(@NotNull StudioProfilers profilers, @Nullable File importedTrace); @VisibleForTesting  CpuProfilerStage(@NotNull StudioProfilers profilers, @Nullable File importedTrace, @NotNull CpuCaptureParser captureParser); boolean isImportTraceMode(); boolean hasUserUsedCpuCapture(); @NotNull RangeSelectionModel getRangeSelectionModel(); @NotNull EaseOutModel getInstructionsEaseOutModel(); AxisComponentModel getCpuUsageAxis(); AxisComponentModel getThreadCountAxis(); AxisComponentModel getTimeAxisGuide(); DetailedCpuUsage getCpuUsage(); CpuStageLegends getLegends(); DurationDataModel<CpuTraceInfo> getTraceDurations(); String getName(); EventMonitor getEventMonitor(); @NotNull CpuProfilerConfigModel getProfilerConfigModel(); @Override void enter(); @Override void exit(); @NotNull UpdatableManager getUpdatableManager(); AspectModel<CpuProfilerAspect> getAspect(); void toggleCapturing(); void startCapturing(); long getCaptureStartTimeNs(); long getCaptureStopTimeNs(); @NotNull TraceIdsIterator getTraceIdsIterator(); @NotNull CpuCaptureParser getCaptureParser(); long currentTimeNs(); @VisibleForTesting void setCapture(@Nullable CpuCapture capture); void setAndSelectCapture(long traceId); @VisibleForTesting void setAndSelectCapture(@NotNull CpuCapture capture); int getSelectedThread(); void setSelectedThread(int id); @NotNull List<ClockType> getClockTypes(); @NotNull ClockType getClockType(); void setClockType(@NotNull ClockType clockType); @Nullable CpuCapture getCapture(); @NotNull CaptureState getCaptureState(); @NotNull TraceInitiationType getCaptureInitiationType(); void setCaptureState(@NotNull CaptureState captureState); @NotNull FilterResult applyCaptureFilter(@NotNull Filter filter); boolean isApiInitiatedTracingInProgress(); @NotNull CpuTraceDataSeries getCpuTraceDataSeries(); @NotNull CpuThreadsModel getThreadStates(); @NotNull CpuKernelModel getCpuKernelModel(); @NotNull CpuFramesModel getFramesModel(); @NotNull CaptureModel getCaptureModel(); void setCaptureDetails(@Nullable CaptureDetails.Type type); @Nullable CaptureDetails getCaptureDetails(); @Override void onNavigated(@NotNull CodeLocation location); static final int CPU_ART_STOP_TIMEOUT_SEC; }
@Test public void traceMissingDataShowsDialog() throws IOException, InterruptedException { myStage.getProfilerConfigModel().setProfilingConfiguration(FakeIdeProfilerServices.ATRACE_CONFIG); CpuProfilerTestUtils.captureSuccessfully(myStage, myCpuService, myTransportService, CpuProfilerTestUtils.traceFileToByteString(TestUtils.getWorkspaceFile(ATRACE_DATA_FILE))); assertThat(myServices.getNotification()).isNull(); myTimer.setCurrentTimeNs(1); CpuProfilerTestUtils.captureSuccessfully(myStage, myCpuService, myTransportService, CpuProfilerTestUtils .traceFileToByteString(TestUtils.getWorkspaceFile(ATRACE_MISSING_DATA_FILE))); assertThat(myServices.getNotification()).isEqualTo(CpuProfilerNotifications.ATRACE_BUFFER_OVERFLOW); }
@Test public void captureStageTransitionTest() throws Exception { myServices.enableCpuCaptureStage(false); myServices.enableEventsPipeline(true); myServices.setShouldProceedYesNoDialog(true); ProfilingConfiguration config = new ProfilingConfiguration("My Config", Cpu.CpuTraceType.ART, Cpu.CpuTraceMode.SAMPLED); CpuProfilerTestUtils.captureSuccessfully(myStage, myCpuService, myTransportService, CpuProfilerTestUtils.readValidTrace()); myStage.getProfilerConfigModel().setProfilingConfiguration(config); assertThat(myStage.getStudioProfilers().getStage()).isEqualTo(myStage); myServices.enableCpuCaptureStage(true); myTimer.setCurrentTimeNs(1); CpuProfilerTestUtils.captureSuccessfully(myStage, myCpuService, myTransportService, CpuProfilerTestUtils.readValidTrace()); assertThat(myStage.getStudioProfilers().getStage().getClass()).isAssignableTo(CpuCaptureStage.class); }
@Test public void cpuMetadataSuccessfulCapture() throws InterruptedException, IOException { CpuCaptureParser.clearPreviouslyLoadedCaptures(); ProfilingConfiguration config = new ProfilingConfiguration("My Config", Cpu.CpuTraceType.ART, Cpu.CpuTraceMode.SAMPLED); config.setProfilingSamplingIntervalUs(10); config.setProfilingBufferSizeInMb(15); myStage.getProfilerConfigModel().setProfilingConfiguration(config); CpuProfilerTestUtils.captureSuccessfully(myStage, myCpuService, myTransportService, CpuProfilerTestUtils.readValidTrace()); CpuCaptureMetadata metadata = ((FakeFeatureTracker)myServices.getFeatureTracker()).getLastCpuCaptureMetadata(); assertThat(metadata.getStatus()).isEqualTo(CpuCaptureMetadata.CaptureStatus.SUCCESS); ProfilingConfiguration metadataConfig = metadata.getProfilingConfiguration(); assertThat(metadataConfig.getProfilingSamplingIntervalUs()).isEqualTo(10); assertThat(metadataConfig.getProfilingBufferSizeInMb()).isEqualTo(15); assertThat(metadataConfig.getTraceType()).isEqualTo(Cpu.CpuTraceType.ART); assertThat(metadataConfig.getMode()).isEqualTo(Cpu.CpuTraceMode.SAMPLED); assertThat(metadata.getParsingTimeMs()).isGreaterThan(0L); assertThat(metadata.getStoppingTimeMs()).isEqualTo(FakeCpuService.FAKE_STOPPING_TIME_MS); assertThat(metadata.getRecordDurationMs()).isGreaterThan(0L); assertThat(metadata.getCaptureDurationMs()).isGreaterThan(0L); assertThat(metadata.getTraceFileSizeBytes()).isGreaterThan(0); }