Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU and Memory Utilisation #114

Open
nagkumar opened this issue Jul 1, 2023 · 5 comments
Open

CPU and Memory Utilisation #114

nagkumar opened this issue Jul 1, 2023 · 5 comments

Comments

@nagkumar
Copy link

nagkumar commented Jul 1, 2023

In my tests I have seen no out of memory but CPU has gone 100% multiple times and most times beyond 50% CPU

image image image

Maybe instead of using the fall loop to invoke the same test, do consider using of https://www.baeldung.com/junit-5-repeated-test so that the junit had the usual method to repeat the as now JUnitPerf not only handling repeat call in the for loop but also doing some work of following @beforeeach @AfterEach etc.. b.t.w JUnit 5 does support multiple methods with @beforeeach and @aftereach...

Using @RepeatedTest at least when junitperf spec says totalExecutions =x, then even JUnit 5 dashboard would also show x test has run x times etc..

Again, this suggestion of mine is meant for JUnitPerf to focus on performance aspects only not to repeat to follow junit 5 test running lifecycle as much as possible. The Close example is https://jmeter.apache.org/api/org/apache/jmeter/protocol/java/sampler/JUnitSampler.html which tests unit tests all externally.. In fact, this sampler only supports JUnit4 and JUnit3, not JUnit 5 yet.. hope someday that would be ready..

In short, depending on JUnitPerfTest Spec, can you think of adding repeat test annotation dynamically and let JUnithandle the rest.. and still would you be able to collect the time taken for latency

@noconnor
Copy link
Owner

noconnor commented Jul 1, 2023

@RepeatedTest does not allow for running parallel executions of the test in a thread pool, which is very useful when load testing API's. It would also not be possible to execute a test for a fix duration (with warmup & rampup periods), which again is useful when load testing API endpoints. If would also not be possible to set a target rate per second (see maxExecutionsPerSecond), again useful for load testing.

Support for running all/multiple BeforeEach and AfterEach methods is already available

To limit CPU usage during the test you can use maxExecutionsPerSecond

@nagkumar
Copy link
Author

nagkumar commented Jul 2, 2023

If would also not be possible to set a target rate per second

but what if the need any needs just totalExecutions=x (lightweight performance testing)

In such min, performance needs @RepeatedTest may still be good. Also, it may also help JUnitPerf to prove their measurements are similar to JUnit 5 (in case you give the option to do perf testing even with RepeatedTest approach for the cases that are applicable.

does not allow for running parallel executions

Not sure why JUnit has this.. even if this is a limitation now, hope they will be able to fix it in the future.

@nagkumar
Copy link
Author

nagkumar commented Jul 2, 2023

To limit CPU usage during the test you can use maxExecutionsPerSecond

May be good to talk about limiting CPU usage control in the comments of this code or rename maxExecutionsPerSecond variable accordingly

  // Test will execute no more that specified "rateLimit" executions per second
  // Default value is no limit
  int maxExecutionsPerSecond() default -1;

@noconnor
Copy link
Owner

noconnor commented Jul 3, 2023

I'll add a note about CPU usage to the main readme page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants