diff --git a/sip/msg_test.go b/sip/msg_test.go index 78aa965..aae98dc 100755 --- a/sip/msg_test.go +++ b/sip/msg_test.go @@ -1249,14 +1249,14 @@ func TestParseMsg(t *testing.T) { } } -func BenchmarkParseMsgFlowroute(b *testing.B) { // 27256 ns/op +func BenchmarkParseMsgFlowroute(b *testing.B) { // 26653 ns/op msg := []byte(flowroute) for i := 0; i < b.N; i++ { sip.ParseMsgBytes(msg) } } -func BenchmarkParseMsgTorture2(b *testing.B) { // 32296 ns/op +func BenchmarkParseMsgTorture2(b *testing.B) { // 31397 ns/op msg := []byte(torture2) for i := 0; i < b.N; i++ { sip.ParseMsgBytes(msg) diff --git a/sip/sip.rl b/sip/sip.rl index 4de7456..eab72c2 100644 --- a/sip/sip.rl +++ b/sip/sip.rl @@ -6,10 +6,15 @@ # the purpose of converting SIP messages into a Msg data structure. This # machine works in tandem with the Ragel machine defined in uri_parse.rl. # -# Perhaps it would have been better if the authors of this protocol had chosen -# to use a binary serialization format like protocol buffers. But instead they -# chose to create a plaintext protocol that looks similar to HTTP requests, -# but are phenomenally more complicated. +# The parser is deterministicly effectively O(k). It's able to parse an +# ordinary INVITE message in less than 30μs, which means 30k messages can be +# parsed per second. Best of all, messages are parsed into a very easy to use +# and transparent data structure. +# +# Perhaps it would have been better if the SIP protocol designers had chosen to +# use a binary serialization format like protocol buffers. But instead they +# chose to create a plaintext protocol that looks similar to HTTP requests, but +# are phenomenally more complicated. # # SIP messages are quite insane. #