This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch CAUSEWAY-3883
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/CAUSEWAY-3883 by this push:
new a351f408c65 CAUSEWAY-3883: improves test measurements
a351f408c65 is described below
commit a351f408c65a2af1e386a6796188c37361ba735a
Author: Dan Haywood <[email protected]>
AuthorDate: Wed Apr 9 10:13:38 2025 +0100
CAUSEWAY-3883: improves test measurements
---
.../services/ProxyFactoryServiceByteBuddy.java | 2 +-
.../testdomain/jpa/JpaInventoryManager.java | 4 +++
.../jdo/WrapperFactoryMetaspaceMemoryLeakTest.java | 37 +++++++++++++---------
3 files changed, 27 insertions(+), 16 deletions(-)
diff --git
a/core/codegen-bytebuddy/src/main/java/org/apache/causeway/core/codegen/bytebuddy/services/ProxyFactoryServiceByteBuddy.java
b/core/codegen-bytebuddy/src/main/java/org/apache/causeway/core/codegen/bytebuddy/services/ProxyFactoryServiceByteBuddy.java
index 0ee892e07fc..2f89e0ca5c6 100644
---
a/core/codegen-bytebuddy/src/main/java/org/apache/causeway/core/codegen/bytebuddy/services/ProxyFactoryServiceByteBuddy.java
+++
b/core/codegen-bytebuddy/src/main/java/org/apache/causeway/core/codegen/bytebuddy/services/ProxyFactoryServiceByteBuddy.java
@@ -70,6 +70,7 @@ public <T> _ProxyFactory<T> factory(
@Override
public Class<? extends T> apply(InvocationHandler handler) {
+// return createClass(handler);
return (Class<? extends T>)
proxyClassByInvocationHandler.computeIfAbsent(handler, this::createClass);
}
@@ -137,7 +138,6 @@ private Object createUsingConstructor(final
InvocationHandler invocationHandler,
final var constructor =
proxyClass.getConstructor(constructorArgTypes == null ? _Constants.emptyClasses
: constructorArgTypes);
return constructor.newInstance(constructorArgs == null ?
_Constants.emptyObjects : constructorArgs);
}
-
};
}
diff --git
a/regressiontests/base/src/main/java/org/apache/causeway/testdomain/jpa/JpaInventoryManager.java
b/regressiontests/base/src/main/java/org/apache/causeway/testdomain/jpa/JpaInventoryManager.java
index 10f8ccbb2d8..9ea9eda0ab4 100644
---
a/regressiontests/base/src/main/java/org/apache/causeway/testdomain/jpa/JpaInventoryManager.java
+++
b/regressiontests/base/src/main/java/org/apache/causeway/testdomain/jpa/JpaInventoryManager.java
@@ -49,6 +49,10 @@ public JpaProduct updateProductPrice(final JpaProduct
product, final double newP
// -- COUNT PRODUCTS
+ @Action
+ public void foo() {
+ }
+
@Action
public int countProducts() {
return getAllProducts().size();
diff --git
a/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/wrapper/jdo/WrapperFactoryMetaspaceMemoryLeakTest.java
b/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/wrapper/jdo/WrapperFactoryMetaspaceMemoryLeakTest.java
index f0ec2722319..1e3900d4937 100644
---
a/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/wrapper/jdo/WrapperFactoryMetaspaceMemoryLeakTest.java
+++
b/regressiontests/persistence-jpa/src/test/java/org/apache/causeway/testdomain/wrapper/jdo/WrapperFactoryMetaspaceMemoryLeakTest.java
@@ -73,28 +73,35 @@ void uninstallFixture() {
@Test
void testWrapper_waitingOnDomainEvent() throws InterruptedException {
-
+ MemoryUsage.measureMetaspace("exercise", ()->{
// with caching
- MemoryUsage.measureMetaspace("whole thing", ()->{
-// extracted(1, 1); // 1,980 KB
-// extracted(1, 2000); // 3,794 KB
-// extracted(20, 1); // 2,468 KB
- extracted(20, 2000); // 3,636 KB
-//
+// exercise(1, 0); // 2,053 KB
+// exercise(1, 2000); // 3,839 KB. // some leakage from
collections
+// exercise(20, 0); // 2,112 KB
+// exercise(20, 2000); // 3,875 KB
+// exercise(2000, 0); // 3,260 KB. // ? increased some, is it
significant; a lot less than without caching
+// exercise(2000, 200); // 4,294 KB.
+// exercise(20000, 0); // 3,265 KB // no noticeable leakage
compared to 2000; MUCH less than without caching
+
// without caching
-// extracted(1, 1); // 2,114 KB
-// extracted(1, 1000); // 9,846 KB
-// extracted(20, 1); // 2,635 KB
-// extracted(20, 2000); // 217,582 KB
+// exercise(1, 0); // 2,244 KB
+// exercise(1, 2000); //. 3,669 KB // some leakage from
collections
+// exercise(20, 0); // 2,440 KB
+// exercise(20, 2000); //. 4,286 KB
+// exercise(2000, 0); // 15,148 KB // significant leakage from
20
+// exercise(2000, 200); // 20,423 KB
+// exercise(20000, 0); //.115,729 KB
});
}
- private void extracted(int instances, int loops) {
- for(int i = 0; i < instances; i++) {
+ private void exercise(int instances, int loops) {
+ for (int i = 0; i < instances; i++) {
val inventoryManager =
factoryService.viewModel(JpaInventoryManager.class);
+ JpaInventoryManager jpaInventoryManager =
wrapper.wrap(inventoryManager);
+ jpaInventoryManager.foo();
- for (var j = 0; j< loops; j++) {
- List<JpaProduct> allProducts =
wrapper.wrap(inventoryManager).getAllProducts();
+ for (var j = 0; j < loops; j++) {
+ List<JpaProduct> allProducts =
jpaInventoryManager.getAllProducts();
allProducts.forEach(product -> {
String unused = product.getName();
});