Skip to content

Commit

Permalink
PerformanceTest: prefer a Release native library over Debug ones
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Sep 20, 2024
1 parent 75a147c commit b7f8160
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/test/java/testjoltjni/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,42 @@ public static boolean loadNativeLibrary(
return success;
}

/**
* Load some flavor of native library, preferably a Release build.
* <p>
* The search order is:
* <ol>
* <li>ReleaseSp</li>
* <li>ReleaseDp</li>
* <li>DebugSp</li>
* <li>DebugDp</li>
* </ol>
*/
public static void loadNativeLibraryRelease() {
File directory = new File("build/libs/joltjni/shared");

boolean success = loadNativeLibrary(directory, "Release", "Sp");
if (success) {
Assert.assertFalse(Jolt.isDoublePrecision());
} else {
success = loadNativeLibrary(directory, "Release", "Dp");
if (success) {
Assert.assertTrue(Jolt.isDoublePrecision());
} else {
success = loadNativeLibrary(directory, "Debug", "Sp");
if (success) {
Assert.assertFalse(Jolt.isDoublePrecision());
} else {
success = loadNativeLibrary(directory, "Debug", "Dp");
if (success) {
Assert.assertTrue(Jolt.isDoublePrecision());
}
}
}
}
Assert.assertTrue(success);
}

/**
* Allocate and initialize a {@code PhysicsSystem} in the customary
* configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private static void Trace(String format, Object... args)
// Program entry point
public static void main(String[] argv) throws IOException
{
TestUtils.loadNativeLibrary();
TestUtils.loadNativeLibraryRelease();
// Install callbacks
Jolt.installDefaultTraceCallback();

Expand Down

0 comments on commit b7f8160

Please sign in to comment.