[hibernate-dev] run a single unit test speed up?

Jason Pyeron jpyeron at pdinc.us
Thu Apr 23 13:03:35 EDT 2020


> -----Original Message-----
> From: Sanne Grinovero
> Sent: Thursday, April 23, 2020 8:43 AM
> 
> On Thu, 23 Apr 2020 at 13:20, Jason Pyeron <jpyeron at pdinc.us> wrote:
> >
> > > -----Original Message-----
> > > From: Sanne Grinovero
> > > Sent: Thursday, April 23, 2020 8:04 AM
> > >
> > > Hi Jason,
> > >
> > > I'm surprised. It's not instantaneous here either, but it doesn't take
> > > minutes - provided you've built the project before and didn't change a
> > > lot of code.
> >
> > Just the one unit test.
> >
> > >
> > > If I run such a test for the first time, possibly after having
> > > switched branches, I'll get test results in ~20 seconds; most of this
> >
> > What versions of tools in your tool chain are you using?
> 
> # Gradle
> Using the gradle wrapper, so the same as what we have in each branch
> of Hibernate ORM.
> I don't think Gradle's version matters, we just recently used version
> 4, then 5, now 6 and they all perform well.
> 
> # JDK
> Shouldn't matter either as I have many versions installed, and from
> different vendors, to run various tests. Never noticed one being
> particularly slow.
> 
> # OS
> I run Fedora Linux exclusively, as most members of the team. Some of
> us are on OSX, some use different Linux distributions.

Hmmm, switched to Centos 7 from Windows 10

BUILD SUCCESSFUL in 48s
27 actionable tasks: 3 executed, 24 up-to-date
[root at localhost hibernate-orm]# nano hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java
[root at localhost hibernate-orm]# git diff
diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java
index 3ec3ffc..0936dcb 100644
--- a/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/cid/CompositeIdFkGeneratedValueIdentityTest.java
@@ -51,7 +51,7 @@ public class CompositeIdFkGeneratedValueIdentityTest extends BaseCoreFunctionalT
                        HeadS head = new HeadS();
                        head.name = "Head by Sequence";
                        session.persist( head );
-                       System.out.println( "VALUE =>" + head.name + "=" + head.hid );
+                       System.out.println( "CHANGED VALUE =>" + head.name + "=" + head.hid );

                        NodeS node = new NodeS();
                        node.hid = head;
[root at localhost hibernate-orm]# ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest
[WARN] Skipping Java module path integration tests because the JDK does not support it

> Task :hibernate-core:compileTestJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 46s
27 actionable tasks: 3 executed, 24 up-to-date
[root at localhost hibernate-orm]#

> 
> > > is spent recompiling. But if I repeat the same command right away, it
> > > will complete in ~1 second.

[root at localhost hibernate-orm]# ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest; ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest; ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest; ./gradlew :hibernate-core:test --tests org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest
...
BUILD SUCCESSFUL in 6m 46s
27 actionable tasks: 27 executed
...
BUILD SUCCESSFUL in 13s
27 actionable tasks: 1 executed, 26 up-to-date
...
BUILD SUCCESSFUL in 11s
27 actionable tasks: 1 executed, 26 up-to-date
...
BUILD SUCCESSFUL in 10s
27 actionable tasks: 1 executed, 26 up-to-date

> > >
> > > What do you see if you repeat the test a second time after having just run it?
> >
> > After multiple builds it stabilized at 90 seconds.
> 
> Very odd. Having some old style spinning drives? AFAIK we all use fast
> solid state drives for development.

SSD too - PM951 NVMe SAMSUNG 1024GB
Intel(R) Xeon(R) CPU E3-1545M v5 @ 2.90GHz, running at average of 3.3GHz
64GB ram

> 
> Thanks,
> Sanne
> 
> >
> > >
> > > Just for reference, a full build runnig all tests on H2 takes 6
> > > minutes on my machine.

6.75m to go from clone to run one test.

> > >
> > > Thanks,
> > > Sanne
> > >
> > >
> > >
> > > On Wed, 22 Apr 2020 at 21:59, Jason Pyeron <jpyeron at pdinc.us> wrote:
> > > >
> > > > I got it down to BUILD SUCCESSFUL in 2m 32s
> > > > 27 actionable tasks: 5 executed, 22 up-to-date
> > > >
> > > > By using
> > > >
> > > > ./gradlew :hibernate-core:test --tests
> > > org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest
> > > >
> > > >
> > > > Package___________________________      Tests   Duration        Success rate
> > > > org.hibernate.test.annotations.cid      1____   0.586s__        100%
> > > >
> > > > For an approximate 250x slow down compared to the test execution, sigh.
> > > >
> > > > > -----Original Message-----
> > > > > From: hibernate-dev-bounces at lists.jboss.org <hibernate-dev-bounces at lists.jboss.org> On
> > > Behalf Of Jason
> > > > > Pyeron
> > > > > Sent: Wednesday, April 22, 2020 4:48 PM
> > > > > To: 'Hibernate Dev' <hibernate-dev at lists.jboss.org>
> > > > > Subject: [hibernate-dev] run a single unit test???? do I really have to manually put -
> > > x for every task
> > > > > I do not want?
> > > > >
> > > > > Does anyone know how to get a single unit test to run without building a battleship
> > > too? Tried in
> > > > > eclipse too.
> > > > >
> > > > > ./gradlew test --tests
> > > org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest
> > > > >
> > > > > ... 5 minutes later ...
> > > > >
> > > > > FAILURE: Build failed with an exception.
> > > > >
> > > > > * What went wrong:
> > > > > Execution failed for task ':documentation:test'.
> > > > > > No tests found for given includes:
> > > > > [org.hibernate.test.annotations.cid.CompositeIdFkGeneratedValueIdentityTest](--tests
> > > filter)
> > > > >
> > > > > * Try:
> > > > > Run with --stacktrace option to get the stack trace. Run with --info or --debug option
> > > to get more log
> > > > > output. Run with --scan to get full insights.
> > > > >
> > > > > * Get more help at https://help.gradle.org
> > > > >
> > > > > Deprecated Gradle features were used in this build, making it incompatible with Gradle
> > > 5.0.
> > > > > Use '--warning-mode all' to show the individual deprecation warnings.
> > > > > See
> > > https://docs.gradle.org/4.10.3/userguide/command_line_interface.html#sec:command_line_warn
> > > ings
> > > > >
> > > > > BUILD FAILED in 4m 38s
> > > > > 36 actionable tasks: 35 executed, 1 up-to-date
> > > > >
> > > > > --
> > > > > Jason Pyeron  | Architect
> > > > > PD Inc        |
> > > > > 10 w 24th St  |
> > > > > Baltimore, MD |
> > > > >
> > > > > .mil: jason.j.pyeron.ctr at mail.mil
> > > > > .com: jpyeron at pdinc.us
> > > > > tel : 202-741-9397
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > _______________________________________________
> > > > > hibernate-dev mailing list
> > > > > hibernate-dev at lists.jboss.org
> > > > > https://lists.jboss.org/mailman/listinfo/hibernate-dev
> > > >
> > > > _______________________________________________
> > > > hibernate-dev mailing list
> > > > hibernate-dev at lists.jboss.org
> > > > https://lists.jboss.org/mailman/listinfo/hibernate-dev
> > > >
> >




More information about the hibernate-dev mailing list