Skip to content

Commit 1eb446d

Browse files
committed
#97 added report package filter for current chart
1 parent bee3451 commit 1eb446d

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

app/src/main/java/com/github/grishberg/profiler/common/settings/JsonSettings.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ class JsonSettings(
342342
override fun filesDir() = filesDirName
343343

344344
override var shouldShowToolbar: Boolean = false
345-
override var lastVersion: String = ""
346345

347346
private fun initWithDefaults() {
348347
initWithDefaultStringValue(SETTINGS_FONT_NAME, "Arial")

core/src/main/java/com/github/grishberg/profiler/analyzer/FlatMethodsReportGenerator.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class FlatMethodsReportGenerator(
1212
private val data: CallTracePanel.ProfilerPanelData
1313
) : ReportGenerator {
1414

15-
override fun generate(file: File, onlyConstructor: Boolean, minimumDurationInMs: Int) {
15+
override fun generate(file: File, onlyConstructor: Boolean, minimumDurationInMs: Int, packageFilter: String) {
1616
val fos = FileOutputStream(file)
1717

1818
BufferedWriter(OutputStreamWriter(fos)).use { bw ->
@@ -24,7 +24,8 @@ class FlatMethodsReportGenerator(
2424
it.profileData.threadEndTimeInMillisecond - it.profileData.threadStartTimeInMillisecond
2525
val globalDuration =
2626
it.profileData.globalEndTimeInMillisecond - it.profileData.globalStartTimeInMillisecond
27-
if (threadDuration > minimumDurationInMs && (!onlyConstructor || isConstructor(it.profileData.name))) {
27+
if (threadDuration > minimumDurationInMs && (!onlyConstructor || isConstructor(it.profileData.name)) &&
28+
(packageFilter.isEmpty() || it.profileData.name.startsWith(packageFilter))) {
2829
bw.write(
2930
String.format(
3031
"%s\t%.3f\t%.3f\t%.3f\t%.3f",

core/src/main/java/com/github/grishberg/profiler/analyzer/ReportGenerator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package com.github.grishberg.profiler.analyzer
33
import java.io.File
44

55
interface ReportGenerator {
6-
fun generate(file: File, onlyConstructor: Boolean, minimumDurationInMs: Int)
6+
fun generate(file: File, onlyConstructor: Boolean, minimumDurationInMs: Int, packageFilter: String)
77
}

core/src/main/java/com/github/grishberg/profiler/ui/dialogs/ReportsGeneratorDialog.kt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import javax.swing.JComponent
1616
import javax.swing.JFileChooser
1717
import javax.swing.JLabel
1818
import javax.swing.JPanel
19+
import javax.swing.JTextField
1920
import javax.swing.border.EmptyBorder
2021
import javax.swing.filechooser.FileNameExtensionFilter
2122

@@ -28,6 +29,7 @@ class ReportsGeneratorDialog(
2829

2930
private val constructorsCheckbox: JCheckBox
3031
private val durationLimit: JNumberField
32+
private val packageFilter: JTextField
3133

3234
init {
3335
val content = JPanel()
@@ -59,6 +61,11 @@ class ReportsGeneratorDialog(
5961
"minimum duration", durationLimit, "If checked - will be exported only constructors"
6062
)
6163

64+
packageFilter = JTextField(20)
65+
addLabelAndField(
66+
content, labelConstraints, fieldConstraints,
67+
"package filter", packageFilter, "If not empty - show methods with given package prefix"
68+
)
6269
fieldConstraints.gridy++
6370
fieldConstraints.gridwidth = 2
6471

@@ -102,11 +109,11 @@ class ReportsGeneratorDialog(
102109

103110
if (userSelection == JFileChooser.APPROVE_OPTION) {
104111
var fileToSave = fileChooser.selectedFile
105-
if (fileToSave.extension.toLowerCase() != "txt") {
112+
if (fileToSave.extension.lowercase() != "txt") {
106113
fileToSave = File(fileToSave.absolutePath + ".txt")
107114
}
108115
settings.reportsFileDialogDir = fileToSave.parent
109-
reportsGeneratorDelegate.generate(fileToSave, constructorsCheckbox.isSelected, durationLimit.value as Int)
116+
reportsGeneratorDelegate.generate(fileToSave, constructorsCheckbox.isSelected, durationLimit.value as Int, packageFilter.text.trim())
110117
isVisible = false
111118
}
112119
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ studioCompilePath=/Applications/Android Studio.app/Contents
88

99
pluginGroup = com.github.grishberg
1010
pluginName = android-methods-profiler
11-
yampVersion = 23.08.25
11+
yampVersion = 24.02.05
1212

1313
# See https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
1414
# for insight into build numbers and IntelliJ Platform versions.

0 commit comments

Comments
 (0)