Skip to content

Commit 6ceb0b6

Browse files
committed
jol
1 parent 2554596 commit 6ceb0b6

File tree

5 files changed

+434
-0
lines changed

5 files changed

+434
-0
lines changed

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ dependencies {
8080
// логирование
8181
testImplementation("org.slf4j", "slf4j-reload4j", "2.1.0-alpha1")
8282

83+
// jol
84+
testImplementation("org.openjdk.jol", "jol-core", "0.16")
85+
8386
// бенчмарк
8487
jmh("org.openjdk.jmh:jmh-core:1.37")
8588
jmhAnnotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:1.37")
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.jol;
23+
24+
import com.github._1c_syntax.jol.memory.MemoryAnalyzer;
25+
26+
public class MemoryAnalyze {
27+
public static void main(String[] args) {
28+
var results = MemoryAnalyzer.analyzeClasses(
29+
"com.github._1c_syntax.bsl.mdo",
30+
"com.github._1c_syntax.bsl.mdclasses"
31+
);
32+
MemoryAnalyzer.printAnalysisReport(results);
33+
}
34+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.jol.memory;
23+
24+
import lombok.Builder;
25+
import lombok.Value;
26+
27+
import java.util.Collections;
28+
import java.util.List;
29+
import java.util.Map;
30+
31+
@Value
32+
@Builder
33+
public class AnalysisResult {
34+
String className;
35+
String simpleClassName;
36+
long instanceSize;
37+
long totalSize;
38+
Map<String, Long> fieldSizes;
39+
List<FieldAlignmentIssue> alignmentIssues;
40+
int wastedBytes;
41+
double alignmentEfficiency;
42+
List<String> optimizationSuggestions;
43+
String error;
44+
45+
public static AnalysisResult error(String className, String error) {
46+
return builder()
47+
.className(className)
48+
.error(error)
49+
.alignmentIssues(Collections.emptyList())
50+
.optimizationSuggestions(Collections.emptyList())
51+
.fieldSizes(Collections.emptyMap())
52+
.build();
53+
}
54+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2025
5+
* Tymko Oleg <olegtymko@yandex.ru>, Maximov Valery <maximovvalery@gmail.com> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.jol.memory;
23+
24+
/**
25+
* Проблема выравнивания поля
26+
*/
27+
record FieldAlignmentIssue(int position, long paddingSize, String description) {
28+
}

0 commit comments

Comments
 (0)