-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pooling max 20 events instead of 1 event at a time in ProcessEpoll, * explicit freeing of out/err/in buffers instead of waiting for JNA GC RefHandler, * reusing of IntByReference to avoid per method malloc call, * updated JNA library to 5.13.0,
- Loading branch information
Showing
7 changed files
with
127 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/test/java/com/zaxxer/nuprocess/LoadTestForStartUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package com.zaxxer.nuprocess; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.concurrent.CountDownLatch; | ||
import java.util.concurrent.ThreadLocalRandom; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
|
||
public class LoadTestForStartUseCase | ||
{ | ||
|
||
@Test | ||
public void testStartLoad() throws InterruptedException | ||
{ | ||
int durationInMs = 3000_000; | ||
long cutOfTime = System.currentTimeMillis() + durationInMs; | ||
int nrOfThreads = (Runtime.getRuntime().availableProcessors() * 2); | ||
CountDownLatch latch = new CountDownLatch(nrOfThreads); | ||
AtomicLong runCountCode0 = new AtomicLong(); | ||
AtomicLong runCountCodeNon0 = new AtomicLong(); | ||
for (int i = 0; i < nrOfThreads; i++) | ||
{ | ||
newThread(latch, cutOfTime, runCountCode0, runCountCodeNon0); | ||
} | ||
|
||
Assert.assertTrue(latch.await(durationInMs + 1_000, TimeUnit.MILLISECONDS)); | ||
System.out.println("runCount 0 = " + runCountCode0.get()); | ||
System.out.println("runCount non-0 = " + runCountCodeNon0.get()); | ||
} | ||
|
||
private void newThread(final CountDownLatch latch, final long cutOfTime, final AtomicLong zeroExit, final AtomicLong nonZeroExit) | ||
{ | ||
new Thread(new Runnable() | ||
{ | ||
public void run() | ||
{ | ||
while (System.currentTimeMillis() < cutOfTime) | ||
{ | ||
final int randomInt = ThreadLocalRandom.current().nextInt(10_000); | ||
|
||
long startTime = System.nanoTime(); | ||
final NuProcess start = new NuProcessBuilder(new NuAbstractProcessHandler() | ||
{ | ||
public void onPreStart(final NuProcess nuProcess) | ||
{ | ||
super.onPreStart(nuProcess); | ||
} | ||
|
||
public void onExit(final int statusCode) | ||
{ | ||
if (statusCode == 0) | ||
{ | ||
zeroExit.incrementAndGet(); | ||
} | ||
else | ||
{ | ||
nonZeroExit.incrementAndGet(); | ||
} | ||
} | ||
}, "echo", "foo" + randomInt).start(); | ||
try | ||
{ | ||
start.waitFor(10, TimeUnit.DAYS); | ||
System.out.println("Took " + ((System.nanoTime() - startTime) / 1000000)); | ||
// start.wantWrite(); | ||
} | ||
catch (InterruptedException e) | ||
{ | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
latch.countDown(); | ||
} | ||
}).start(); | ||
} | ||
} |