Page History
...
성능제약이 잘 작동하는지도 검증할수 있습니다.
이벤트가를 이벤트는 N개 동시 발생하며, 소비가 되는구간에서 성능카운트를 1올려줍니다.발생시킬수 있지만, TPS제약을 할수있는 ThrottleLimitActor 가 준비되었으며
| Code Block | ||
|---|---|---|
| ||
[Theory(DisplayName = "테스트 n초당 1회 호출제약")]
[InlineData(5, 1, false)]
public void ThrottleLimitTest(int givenTestCount, int givenLimitSeconds, bool isPerformTest)
{
.......
// Create ThrottleLimit Actor
throttleLimitActor = actorSystem.ActorOf(Props.Create(() => new ThrottleLimitActor(1, givenLimitSeconds, 1000)));
throttleLimitActor.Tell(new SetTarget(probe))
for (int i = 0; i < givenTestCount; i++)
{
throttleLimitActor.Tell(new EventCmd()
{
Message = "test",
});
}
//Then : Safe processing within N seconds limit
for (int i = 0; i < givenTestCount; i++)
{
probe.ExpectMsg<EventCmd>(message =>
{
Assert.Equal("test", message.Message);
});
output.WriteLine($"[{DateTime.Now}] - GTPRequestCmd");
if (isPerformTest)
{
_dictionary.Add(_key++, _key);
_addCounter.Increment();
}
}
...........
} |
...
샘플 코드 : https://github.com/psmon/NetCoreLabs/blob/main/ActorLibTest/tools/ThrottleLimitActorTest.cs
여기서 확장된 개념이 소비자의 소비능력을 측정하여 생산량을 동적 TPS조절할수 있는 조절기를 설계하는것이 BackPressure 입니다.
GC 성능 테스트기
...
| Code Block |
|---|
---------- Measurements ---------- Metric : TotalCollections [Gen0] Per Second ( collections ) Average : 251.73166139361632 Max : 305.97882626522244 Min : 178.82369771642138 Std. Deviation : 47.515272144026895 Std. Error : 15.025648361787713 Per Test ( collections ) Average : 1 Max : 1 Min : 1 Std. Deviation : 0 Std. Error : 0 ---------- Metric : TotalCollections [Gen1] Per Second ( collections ) Average : 251.73166139361632 Max : 305.97882626522244 Min : 178.82369771642138 Std. Deviation : 47.515272144026895 Std. Error : 15.025648361787713 Per Test ( collections ) Average : 1 Max : 1 Min : 1 Std. Deviation : 0 Std. Error : 0 |
...
이상 유닛테스트와 함께 심플한 성능테스트를 함께 할수 있는 방법을 살펴보았으며
측정할 수 없으면 성능 개선을 할수 없는것과 마찮가지로 마찬가지로 여기서 이용된 기술과 관련기술 링크도 첨부합니다.
JUnit with Bench
자바에서는 JHM를 이용하여 마이크로 벤치마크할수 있으며 대응하는 버전도 동일하게 준비되어있습니다.
참고링크 링크 : https://
...
...
com/psmon/java-labs/blob/master/springweb/src/jmh/java/com/webnori/springweb/akka/README.md
참고링크 :
- https://getakka.net/articles/articles/actors/testing-actor-systems.html
- https://nbench.io/
- https://github.com/Pro-Coded-External/Pro.NBench.xUnit
- Introducing NBench - Automated Performance Testing and Benchmarking for .NET
- https://blog.knoldus.com/backpressure-in-akka-stream/
- https://www.baeldung.com/java-microbenchmark-harness
