BENCH Fix TCP options pre-allocation.
BENCH Fix TCP options pre-allocation.

Somewhere along the way (probably when I converted TCP to DecodeFromBytes), I
stopped using the preallocated options.  This rolls that back.  TCP decoding
gains about a 40% speedup from this, as far as I can tell.

----------------------------------------------------------
BENCHMARK_MARKER_DO_NOT_CHANGE
----------------------------------------------------------

Go version go version go1.1 linux/amd64

TEST BENCHMARKS
PASS
BenchmarkTypeAssertion	500000000	         4.10 ns/op
BenchmarkMapLookup	500000000	         4.13 ns/op
BenchmarkNilMapLookup	1000000000	         3.01 ns/op
BenchmarkNilMapLookupWithNilCheck	2000000000	         0.83 ns/op
BenchmarkArrayLookup	2000000000	         0.61 ns/op
BenchmarkTypeToInterface1	2000000000	         0.80 ns/op
BenchmarkTypeToInterface2	2000000000	         0.53 ns/op
BenchmarkPassDecodeOptionsByValue	2000000000	         0.27 ns/op
BenchmarkPassDecodeOptionsByPointer	2000000000	         0.27 ns/op
BenchmarkLockOSThread	500000000	         4.01 ns/op
BenchmarkUnlockOSThread	500000000	         4.51 ns/op
BenchmarkLockUnlockOSThread	200000000	         9.36 ns/op
BenchmarkLockDeferUnlockOSThread	20000000	        84.7 ns/op
BenchmarkUnbufferedChannel	10000000	       252 ns/op
BenchmarkSmallBufferedChannel	10000000	       297 ns/op
BenchmarkLargeBufferedChannel	10000000	       297 ns/op
BenchmarkEndpointFastHashShort	100000000	        15.2 ns/op
BenchmarkEndpointFastHashLong	50000000	        33.3 ns/op
BenchmarkFlowFastHashShort	100000000	        22.0 ns/op
BenchmarkFlowFastHashLong	50000000	        56.4 ns/op
ok  	code.google.com/p/gopacket	42.685s
PASS
BenchmarkLayerClassSliceContains	2000000000	         1.09 ns/op
BenchmarkLayerClassMapContains	500000000	         4.06 ns/op
BenchmarkLazyNoCopyEthLayer	 2000000	       977 ns/op
BenchmarkLazyNoCopyIPLayer	 1000000	      1528 ns/op
BenchmarkLazyNoCopyTCPLayer	 1000000	      2390 ns/op
BenchmarkLazyNoCopyAllLayers	 1000000	      2621 ns/op
BenchmarkDefault	 1000000	      2981 ns/op
BenchmarkSerializeTcpNoOptions	 5000000	       408 ns/op
BenchmarkSerializeTcpFixLengths	 5000000	       413 ns/op
BenchmarkSerializeTcpComputeChecksums	 5000000	       734 ns/op
BenchmarkSerializeTcpFixLengthsComputeChecksums	 5000000	       740 ns/op
BenchmarkLazy	 1000000	      1221 ns/op
BenchmarkNoCopy	 1000000	      2266 ns/op
BenchmarkLazyNoCopy	 5000000	       526 ns/op
BenchmarkKnownStack	10000000	       189 ns/op
BenchmarkDecodingLayerParserIgnorePanic	10000000	       242 ns/op
BenchmarkDecodingLayerParserHandlePanic	 5000000	       323 ns/op
BenchmarkAlloc	50000000	        30.1 ns/op
BenchmarkFlow	20000000	       105 ns/op
BenchmarkEndpoints	50000000	        49.2 ns/op
BenchmarkTCPLayerFromDecodedPacket	100000000	        11.5 ns/op
BenchmarkTCPLayerClassFromDecodedPacket	50000000	        35.4 ns/op
BenchmarkTCPTransportLayerFromDecodedPacket	1000000000	         2.81 ns/op
BenchmarkDecodeFuncCallOverheadDirectCall	2000000000	         1.06 ns/op
BenchmarkDecodeFuncCallOverheadDecoderCall	500000000	         6.06 ns/op
BenchmarkDecodeFuncCallOverheadArrayCall	200000000	         9.72 ns/op
BenchmarkFmtVerboseString	   20000	     85280 ns/op
BenchmarkPacketString	   50000	     71536 ns/op
BenchmarkPacketDumpString	   50000	     71584 ns/op
BenchmarkDecodeICMP	 1000000	      1811 ns/op
BenchmarkDecodeICMP6	 1000000	      2043 ns/op
BenchmarkDecodeMPLS	 1000000	      2020 ns/op
BenchmarkDecodePPPoE_ICMPv6	 1000000	      2583 ns/op
BenchmarkDecodePacketIPSecESP	 1000000	      1618 ns/op
ok  	code.google.com/p/gopacket/layers	90.393s

PCAP BENCHMARK
Local pcap file /tmp/gopacket_benchmark.pcap doesn't exist, reading from http://www.ll.mit.edu/mission/communications/cyber/CSTcorpora/ideval/data/1999/training/week1/tuesday/inside.tcpdump.gz
Successfully read 341401548 bytes from url, unzipped to local storage
Reading file once through to hopefully cache most of it
Read in file /tmp/gopacket_benchmark.pcap , total of 341401548 bytes
Opening file "/tmp/gopacket_benchmark.pcap" for read
Reading all packets into memory with BufferPacketSource.
Reading packet data into memory: 1237119 packets in 967.493632ms, 782ns per packet
Time to read packet data into memory from file: 967.519388ms
Benchmarking decode 1/10
	Read in 1237119 packets in 2.409616949s, 1.947us per packet
Benchmarking decode 2/10
	Read in 1237119 packets in 2.109402471s, 1.705us per packet
Benchmarking decode 3/10
	Read in 1237119 packets in 2.004711572s, 1.62us per packet
Benchmarking decode 4/10
	Read in 1237119 packets in 2.027007763s, 1.638us per packet
Benchmarking decode 5/10
	Read in 1237119 packets in 2.03273311s, 1.643us per packet
Benchmarking decode 6/10
	Read in 1237119 packets in 2.034027659s, 1.644us per packet
Benchmarking decode 7/10
	Read in 1237119 packets in 2.034205326s, 1.644us per packet
Benchmarking decode 8/10
	Read in 1237119 packets in 2.033280517s, 1.643us per packet
Benchmarking decode 9/10
	Read in 1237119 packets in 2.036075271s, 1.645us per packet
Benchmarking decode 10/10
	Read in 1237119 packets in 2.049170902s, 1.656us per packet
----------------------------------------------------------
BENCHMARKING AGAINST COMMIT 3b909897916cebdca25f2b69c91df08a02bcc84f
----------------------------------------------------------

OLD TEST BENCHMARKS
PASS
BenchmarkTypeAssertion	500000000	         4.08 ns/op
BenchmarkMapLookup	500000000	         4.73 ns/op
BenchmarkNilMapLookup	500000000	         3.46 ns/op
BenchmarkNilMapLookupWithNilCheck	2000000000	         0.94 ns/op
BenchmarkArrayLookup	2000000000	         0.63 ns/op
BenchmarkTypeToInterface1	2000000000	         0.94 ns/op
BenchmarkTypeToInterface2	2000000000	         0.63 ns/op
BenchmarkPassDecodeOptionsByValue	2000000000	         0.31 ns/op
BenchmarkPassDecodeOptionsByPointer	2000000000	         0.31 ns/op
BenchmarkLockOSThread	500000000	         4.70 ns/op
BenchmarkUnlockOSThread	500000000	         5.21 ns/op
BenchmarkLockUnlockOSThread	200000000	         9.30 ns/op
BenchmarkLockDeferUnlockOSThread	20000000	        84.6 ns/op
BenchmarkUnbufferedChannel	10000000	       248 ns/op
BenchmarkSmallBufferedChannel	10000000	       293 ns/op
BenchmarkLargeBufferedChannel	10000000	       294 ns/op
BenchmarkEndpointFastHashShort	100000000	        14.6 ns/op
BenchmarkEndpointFastHashLong	50000000	        32.4 ns/op
BenchmarkFlowFastHashShort	100000000	        21.3 ns/op
BenchmarkFlowFastHashLong	50000000	        56.2 ns/op
ok  	code.google.com/p/gopacket	43.232s
warning: building out-of-date packages:
	code.google.com/p/gopacket
installing these packages with 'go test -i' will speed future tests.

PASS
BenchmarkLayerClassSliceContains	2000000000	         1.25 ns/op
BenchmarkLayerClassMapContains	500000000	         4.75 ns/op
BenchmarkLazyNoCopyEthLayer	 1000000	      1119 ns/op
BenchmarkLazyNoCopyIPLayer	 1000000	      1773 ns/op
BenchmarkLazyNoCopyTCPLayer	 1000000	      2803 ns/op
BenchmarkLazyNoCopyAllLayers	 1000000	      3044 ns/op
BenchmarkDefault	 1000000	      3481 ns/op
BenchmarkSerializeTcpNoOptions	 5000000	       436 ns/op
BenchmarkSerializeTcpFixLengths	 5000000	       410 ns/op
BenchmarkSerializeTcpComputeChecksums	 5000000	       734 ns/op
BenchmarkSerializeTcpFixLengthsComputeChecksums	 5000000	       738 ns/op
BenchmarkLazy	 1000000	      1208 ns/op
BenchmarkNoCopy	 1000000	      2275 ns/op
BenchmarkLazyNoCopy	 5000000	       522 ns/op
BenchmarkKnownStack	10000000	       188 ns/op
BenchmarkDecodingLayerParserIgnorePanic	10000000	       241 ns/op
BenchmarkDecodingLayerParserHandlePanic	 5000000	       328 ns/op
BenchmarkAlloc	50000000	        30.0 ns/op
BenchmarkFlow	20000000	       108 ns/op
BenchmarkEndpoints	50000000	        49.2 ns/op
BenchmarkTCPLayerFromDecodedPacket	100000000	        11.6 ns/op
BenchmarkTCPLayerClassFromDecodedPacket	50000000	        36.1 ns/op
BenchmarkTCPTransportLayerFromDecodedPacket	1000000000	         2.82 ns/op
BenchmarkDecodeFuncCallOverheadDirectCall	2000000000	         1.06 ns/op
BenchmarkDecodeFuncCallOverheadDecoderCall	500000000	         6.02 ns/op
BenchmarkDecodeFuncCallOverheadArrayCall	200000000	         9.69 ns/op
BenchmarkFmtVerboseString	   20000	     86878 ns/op
BenchmarkPacketString	   50000	     71415 ns/op
BenchmarkPacketDumpString	   50000	     71316 ns/op
BenchmarkDecodePacketIPSecESP	 1000000	      1558 ns/op
ok  	code.google.com/p/gopacket/layers	82.346s

OLD PCAP BENCHMARK
Reading file once through to hopefully cache most of it
Read in file /tmp/gopacket_benchmark.pcap , total of 341401548 bytes
Opening file "/tmp/gopacket_benchmark.pcap" for read
Reading all packets into memory with BufferPacketSource.
Reading packet data into memory: 1237119 packets in 956.330474ms, 773ns per packet
Time to read packet data into memory from file: 956.360471ms
Benchmarking decode 1/10
	Read in 1237119 packets in 2.402407032s, 1.941us per packet
Benchmarking decode 2/10
	Read in 1237119 packets in 2.318985798s, 1.874us per packet
Benchmarking decode 3/10
	Read in 1237119 packets in 2.358850005s, 1.906us per packet
Benchmarking decode 4/10
	Read in 1237119 packets in 2.378795366s, 1.922us per packet
Benchmarking decode 5/10
	Read in 1237119 packets in 2.386797395s, 1.929us per packet
Benchmarking decode 6/10
	Read in 1237119 packets in 2.389922175s, 1.931us per packet
Benchmarking decode 7/10
	Read in 1237119 packets in 2.390623216s, 1.932us per packet
Benchmarking decode 8/10
	Read in 1237119 packets in 2.404801431s, 1.943us per packet
Benchmarking decode 9/10
	Read in 1237119 packets in 2.391056175s, 1.932us per packet
Benchmarking decode 10/10
	Read in 1237119 packets in 2.413339721s, 1.95us per packet

scroot/gopacket,scroot/gopacket,xuzhaokui/gopacket,skyportsystems/gopacket,LrsK/gopacket,ccordes-snaproute/gopacket,clarktrimble/gopacket,adriantam/gopacket,packetb-old/gopacket,nhooyr/gopacket,UIKit0/gopacket-1,breml/gopacket,ross-williams/gopacket,hkwi/gopacket,josephcopenhaver/gopacket,urso/gopacket,vtolstov/gopacket,dazer-chen/gopacket,rouzier/gopacket,dazer-chen/gopacket,dutchcoders/gopacket,scroot/gopacket,lokikiller/gopacket,UIKit0/gopacket-1,dutchcoders/gopacket,packetb-old/gopacket,chapayGhub/gopacket,lokikiller/gopacket,google/gopacket,skyportsystems/gopacket,wheelcomplex/gopacket,skyportsystems/gopacket,levigross/gopacket,cmillward/gopacket,aeppert/gopacket,clarktrimble/gopacket,breml/gopacket,1d4Nf6/gopacket,chapayGhub/gopacket,levigross/gopacket,LrsK/gopacket,levigross/gopacket,chapayGhub/gopacket,urso/gopacket,zerklabs/gopacket,josephcopenhaver/gopacket,ccordes-snaproute/gopacket,rouzier/gopacket,packetbeat/gopacket,josephcopenhaver/gopacket,dutchcoders/gopacket,breml/gopacket,adriantam/gopacket,vtolstov/gopacket,ross-williams/gopacket,cmillward/gopacket,xuzhaokui/gopacket,aeppert/gopacket,packetb-old/gopacket,packetbeat/gopacket,ross-williams/gopacket,nhooyr/gopacket,packetb-old/gopacket,google/gopacket,nhooyr/gopacket,adriantam/gopacket,wheelcomplex/gopacket,ccordes-snaproute/gopacket,xuzhaokui/gopacket,hkwi/gopacket,wheelcomplex/gopacket,lokikiller/gopacket,dazer-chen/gopacket,UIKit0/gopacket-1,hkwi/gopacket,aeppert/gopacket,1d4Nf6/gopacket,clarktrimble/gopacket,urso/gopacket,zerklabs/gopacket,packetbeat/gopacket,zerklabs/gopacket,LrsK/gopacket,packetbeat/gopacket,vtolstov/gopacket,1d4Nf6/gopacket,cmillward/gopacket,google/gopacket,rouzier/gopacket