Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

비동기적으로 작동하는 이벤트(Actor메시지)의 성능을 유닛테스트기를 활용하여 측정할수 있는 방법을 소개합니다.

이 샘플에서는 액터성능 테스트가 포함되어 있지만 예시되어있지만 액터모델과 상관없이 상관없이  유닛테스트내에서 성능테스트툴을 심플한 측정모드를 이용할수 있습니다.

Table of Contents

테스트 탐색기

...

테스트 탐색기를 통해 성능유닛 테스트를 수행하고 측정할수 있습니다.

...

위코드는 단순하게 이벤트 생성에서만 측정하는것이아닌 메시지함에서 확인함까지 완료하는 검증로직이며

Message delivery once 까지 검증을 수준을 검증 합니다.


Akka테스트 툴킷

Image Added

메시지 수신함에서 메시지가 있는지를 하나씩 꺼내 체크하는 Akka Testkit이 제공하는 큐검사 방식으로

...

Code Block
testProbe.ExpectMsg("world");



Nbench에서 지원하는 함수로 수신검사가 되면 완료되면 성능카운터를 1 증가하는 심플한 측정방법입니다. 기본유닛테스트기에서는 로직검사만 수행할수 증가합니다.

성능 테스트모드일때만 수행할수 있으며 기본 유닛테스트에서는 성능테스트 제외하여 도메인검증에 집중할수 있습니다.

Code Block
_addCounter.Increment();

...

Code Block
        [NBenchFact]        
        [PerfBenchmark(NumberOfIterations = 3, RunMode = RunMode.Throughput,
        RunTimeMilliseconds = 1000, TestMode = TestMode.Test)]
        [CounterThroughputAssertion("TestCounter", MustBe.GreaterThan, 1000.0d)]
        [CounterTotalAssertion("TestCounter", MustBe.GreaterThan, 1500.0d)]
        [CounterMeasurement("TestCounter")]
        public void RoundRobinPoolTestPerformanceTest()
        {
            RoundRobinPoolTest(5, 3000, true);
        }

...

주요 설정 옵션은 다음과 같습니다.

  • NumberOfIterations  : 테스트 횟수
  • RunTimeMilliseconds : 측정 기준초 ,   1000ms 여야지 TPS(Test Per Sec) 측정입니다.
  • CounterThroughputAssertion : 최소 완료 회수로 이 값을 준수를 못하면 성능 테스트 실패합니다.
  • CounterTotalAssertion : 평균 완료회수로 이 값을 준수못하면 성능 테스트 실패합니다.



Image Added

성능 유닛트세트가 작성되면, VS-IDE가 제공하는 테스트 탐색기를 통해서도 수행할수 있습니다.



성능측정 리포트

...

...

Code Block
    [PASS] Expected [Counter] TestCounter to must be greater than 1,000.00 operations; actual value was 94,160.06 operations.
    
    [PASS] Expected [Counter] TestCounter to must be greater than 1,500.00 operations; actual value was 93,000.00 operations.
    
    
    ---------- Measurements ----------
    
    Metric : [Counter] TestCounter
    
    Per Second ( operations )
    Average         : 94160.06329051661
    Max             : 94937.13528317196
    Min             : 93266.78965179897
    Std. Deviation  : 841.2138544819605
    Std. Error      : 485.6750453312026
    
    Per Test ( operations )
    Average         : 93000
    Max             : 93000
    Min             : 93000
    Std. Deviation  : 0
    Std. Error      : 0
    
    ----------

성능측정이 통과가 되면 간단한 리포팅이 표시가 되며 성능측정이 통과유무의 정보가 표현됩니다.

  •  [PASS] Expected [Counter] TestCounter to must be greater than 1,000.00 operations; actual value was 94,160.06 operations.
    • CounterThroughputAssertion 에서 설정된 값 이상인 최소 TPS 통과됨을 의미하며 추가로 94160 수행되었음을 표현합니다.
  • [PASS] Expected [Counter] TestCounter to must be greater than 1,500.00 operations; actual value was 93,000.00 operations.
    • CounterTotalAssertion  에서 설정된 값 이상인 평균 TPS가 통과됨을 의미하며 평균 수행횟수가 93000임을 표현합니다.



참고링크 :

...