[STUN] benchmark the performance of STUN
rainliu opened this issue · 4 comments
pion stun
go test -bench .
goos: windows
goarch: amd64
pkg: github.com/pion/stun
cpu: AMD Ryzen 9 5950X 16-Core Processor
BenchmarkMappedAddress_AddTo-32 47982338 26.28 ns/op 0 B/op 0 allocs/op
BenchmarkAlternateServer_AddTo-32 40561779 28.80 ns/op 0 B/op 0 allocs/op
BenchmarkAgent_GC-32 631060 1926 ns/op 0 B/op 0 allocs/op
BenchmarkAgent_Process-32 59928684 21.24 ns/op 0 B/op 0 allocs/op
BenchmarkMessage_GetNotFound-32 528635524 2.343 ns/op 0 B/op 0 allocs/op
BenchmarkMessage_Get-32 451129684 2.827 ns/op 0 B/op 0 allocs/op
BenchmarkClient_Do-32 1299387 1226 ns/op 0 B/op 0 allocs/op
BenchmarkErrorCode_AddTo-32 44445925 42.66 ns/op 0 B/op 0 allocs/op
BenchmarkErrorCodeAttribute_AddTo-32 52178449 32.62 ns/op 0 B/op 0 allocs/op
BenchmarkErrorCodeAttribute_GetFrom-32 194328836 6.317 ns/op 0 B/op 0 allocs/op
BenchmarkFingerprint_AddTo-32 25533055 45.12 ns/op 975.20 MB/s 0 B/op 0 allocs/op
BenchmarkFingerprint_Check-32 32434273 31.56 ns/op 1647.84 MB/s 0 B/op 0 allocs/op
BenchmarkBuildOverhead/Build-32 9230839 135.8 ns/op 0 B/op 0 allocs/op
BenchmarkBuildOverhead/BuildNonPointer-32 4615401 254.9 ns/op 76 B/op 4 allocs/op
BenchmarkBuildOverhead/Raw-32 10344871 108.2 ns/op 0 B/op 0 allocs/op
BenchmarkMessage_ForEach-32 59140023 22.82 ns/op 0 B/op 0 allocs/op
BenchmarkMessageIntegrity_AddTo-32 1538462 798.2 ns/op 25.06 MB/s 0 B/op 0 allocs/op
BenchmarkMessageIntegrity_Check-32 1530613 741.9 ns/op 43.13 MB/s 0 B/op 0 allocs/op
BenchmarkMessage_Write-32 60004500 21.27 ns/op 1316.69 MB/s 0 B/op 0 allocs/op
BenchmarkMessageType_Value-32 1000000000 0.4370 ns/op 0 B/op 0 allocs/op
BenchmarkMessage_WriteTo-32 183343208 6.668 ns/op 0 B/op 0 allocs/op
BenchmarkMessage_ReadFrom-32 63161218 16.21 ns/op 1233.59 MB/s 0 B/op 0 allocs/op
BenchmarkMessage_ReadBytes-32 100000000 10.51 ns/op 1902.91 MB/s 0 B/op 0 allocs/op
BenchmarkIsMessage-32 1000000000 0.9455 ns/op 21152.60 MB/s 0 B/op 0 allocs/op
BenchmarkMessage_NewTransactionID-32 9194676 120.3 ns/op 0 B/op 0 allocs/op
BenchmarkMessageFull-32 9337772 132.6 ns/op 0 B/op 0 allocs/op
BenchmarkMessageFullHardcore-32 21536079 59.78 ns/op 0 B/op 0 allocs/op
BenchmarkMessage_WriteHeader-32 165629160 8.456 ns/op 0 B/op 0 allocs/op
BenchmarkMessage_CloneTo-32 38710801 30.13 ns/op 2256.59 MB/s 0 B/op 0 allocs/op
BenchmarkMessage_AddTo-32 872665710 1.444 ns/op 0 B/op 0 allocs/op
BenchmarkDecode-32 75000937 14.67 ns/op 0 B/op 0 allocs/op
BenchmarkUsername_AddTo-32 70594464 15.09 ns/op 0 B/op 0 allocs/op
BenchmarkUsername_GetFrom-32 219573715 5.763 ns/op 0 B/op 0 allocs/op
BenchmarkNonce_AddTo-32 52175500 20.63 ns/op 0 B/op 0 allocs/op
BenchmarkNonce_AddTo_BadLength-32 387100269 3.458 ns/op 0 B/op 0 allocs/op
BenchmarkNonce_GetFrom-32 241686682 5.137 ns/op 0 B/op 0 allocs/op
BenchmarkUnknownAttributes/AddTo-32 46156153 23.50 ns/op 0 B/op 0 allocs/op
BenchmarkUnknownAttributes/GetFrom-32 92318343 11.25 ns/op 0 B/op 0 allocs/op
BenchmarkXOR-32 153180528 7.488 ns/op 136751.80 MB/s
BenchmarkXORSafe-32 23222464 45.04 ns/op 22735.86 MB/s
BenchmarkXORFast-32 161943253 7.262 ns/op 141011.81 MB/s
BenchmarkXORMappedAddress_AddTo-32 47040007 31.71 ns/op 0 B/op 0 allocs/op
BenchmarkXORMappedAddress_GetFrom-32 54548677 20.30 ns/op 0 B/op 0 allocs/op
PASS
ok github.com/pion/stun 69.741s
cargo bench
BenchmarkMappedAddress_AddTo time: [58.582 ns 58.913 ns 59.320 ns]
BenchmarkAlternateServer_AddTo time: [67.263 ns 67.958 ns 68.809 ns]
BenchmarkAgent_GC time: [334.45 ns 340.38 ns 348.49 ns]
BenchmarkAgent_Process time: [31.066 ns 31.616 ns 32.422 ns]
BenchmarkMessage_GetNotFound time: [2.9481 ns 2.9684 ns 2.9924 ns]
BenchmarkMessage_Get time: [10.381 ns 10.476 ns 10.592 ns]
BenchmarkErrorCode_AddTo time: [95.523 ns 96.278 ns 97.213 ns]
BenchmarkErrorCodeAttribute_AddTo time: [68.834 ns 69.436 ns 70.207 ns]
BenchmarkErrorCodeAttribute_GetFrom time: [20.772 ns 20.881 ns 21.018 ns]
BenchmarkFingerprint_AddTo time: [590.18 ns 592.25 ns 594.27 ns]
BenchmarkFingerprint_Check time: [554.62 ns 556.65 ns 558.80 ns]
BenchmarkBuildOverhead/Build time: [858.07 ns 863.46 ns 869.54 ns]
BenchmarkBuildOverhead/Raw time: [797.91 ns 802.05 ns 807.02 ns]
BenchmarkMessageIntegrity_AddTo time: [565.54 ns 569.12 ns 573.24 ns]
BenchmarkMessageIntegrity_Check time: [541.66 ns 545.32 ns 549.50 ns]
BenchmarkMessage_Write time: [51.618 ns 51.960 ns 52.370 ns]
BenchmarkMessageType_Value time: [1.2505 ns 1.2587 ns 1.2685 ns]
BenchmarkMessage_WriteTo time: [7.1927 ns 7.2417 ns 7.2995 ns]
BenchmarkMessage_ReadFrom time: [34.458 ns 34.712 ns 35.012 ns]
BenchmarkMessage_ReadBytes time: [8.4093 ns 8.5257 ns 8.6719 ns]
BenchmarkIsMessage time: [1.0370 ns 1.0418 ns 1.0469 ns]
BenchmarkMessage_NewTransactionID time: [10.779 ns 10.825 ns 10.875 ns]
BenchmarkMessageFull time: [1.0287 us 1.0516 us 1.0760 us]
BenchmarkMessageFullHardcore time: [128.23 ns 129.85 ns 131.78 ns]
BenchmarkMessage_WriteHeader time: [5.5443 ns 5.5938 ns 5.6525 ns]
BenchmarkMessage_CloneTo time: [42.627 ns 42.925 ns 43.304 ns]
BenchmarkMessage_AddTo time: [1.4792 ns 1.4875 ns 1.4974 ns]
BenchmarkDecode time: [26.393 ns 26.805 ns 27.327 ns]
BenchmarkUsername_AddTo time: [35.854 ns 36.143 ns 36.487 ns]
BenchmarkUsername_GetFrom time: [20.628 ns 20.741 ns 20.887 ns]
BenchmarkNonce_AddTo time: [62.731 ns 63.073 ns 63.501 ns]
BenchmarkNonce_AddTo_BadLength time: [3.9986 ns 4.0262 ns 4.0618 ns]
BenchmarkNonce_GetFrom time: [20.442 ns 20.546 ns 20.669 ns]
BenchmarkUnknownAttributes/AddTo time: [45.631 ns 45.942 ns 46.348 ns]
BenchmarkUnknownAttributes/GetFrom time: [14.149 ns 14.238 ns 14.348 ns]
BenchmarkXOR time: [443.43 ns 446.58 ns 450.05 ns]
BenchmarkXORMappedAddress_AddTo time: [89.822 ns 90.385 ns 91.068 ns]
BenchmarkXORMappedAddress_GetFrom time: [46.231 ns 46.497 ns 46.794 ns]
lot of things to improve
benchmarking is done, will create separate issue to track performance improvement based on this benchmark