[1]에서 문자열을 다룰 때 StrictTextBuilder의 성능을 비교하는 예제에서 Builder의 성능이 더 좋다고 설명한다. 그런데 내 PC에서 같은 코드를 실행했는데 결과가 반대로 나왔다. 이상해서 문자열 길이를 늘렸더니 책에서 말한대로 나왔다.

ghci> concatSpeedTest 50000
0.004451s
0.04721s
ghci> concatSpeedTest 500000
0.062405s
0.023449s
ghci> concatSpeedTest 5000000
0.511402s
0.205632s

  1. Chris Martin, Julie Moronuki, 《Sockets and Pipes》 ↩︎

3

If you have a fediverse account, you can reply to this note from your own instance. Search https://hackers.pub/ap/notes/019632ef-21a1-7f7d-9cd6-afd9c950909e on your instance and reply to it.

@curry박준규 짧을 때는 길이가 chunk size의 배수냐가 중요할 겁니다. 길 때는 평균적인 성능이 나오겠지만요.

3