You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

914 lines
17 KiB

  1. package cmd
  2. // Code generated by github.com/tinylib/msgp DO NOT EDIT.
  3. import (
  4. "bytes"
  5. "testing"
  6. "github.com/tinylib/msgp/msgp"
  7. )
  8. func TestMarshalUnmarshalActiveWorkerStat(t *testing.T) {
  9. v := ActiveWorkerStat{}
  10. bts, err := v.MarshalMsg(nil)
  11. if err != nil {
  12. t.Fatal(err)
  13. }
  14. left, err := v.UnmarshalMsg(bts)
  15. if err != nil {
  16. t.Fatal(err)
  17. }
  18. if len(left) > 0 {
  19. t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
  20. }
  21. left, err = msgp.Skip(bts)
  22. if err != nil {
  23. t.Fatal(err)
  24. }
  25. if len(left) > 0 {
  26. t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
  27. }
  28. }
  29. func BenchmarkMarshalMsgActiveWorkerStat(b *testing.B) {
  30. v := ActiveWorkerStat{}
  31. b.ReportAllocs()
  32. b.ResetTimer()
  33. for i := 0; i < b.N; i++ {
  34. v.MarshalMsg(nil)
  35. }
  36. }
  37. func BenchmarkAppendMsgActiveWorkerStat(b *testing.B) {
  38. v := ActiveWorkerStat{}
  39. bts := make([]byte, 0, v.Msgsize())
  40. bts, _ = v.MarshalMsg(bts[0:0])
  41. b.SetBytes(int64(len(bts)))
  42. b.ReportAllocs()
  43. b.ResetTimer()
  44. for i := 0; i < b.N; i++ {
  45. bts, _ = v.MarshalMsg(bts[0:0])
  46. }
  47. }
  48. func BenchmarkUnmarshalActiveWorkerStat(b *testing.B) {
  49. v := ActiveWorkerStat{}
  50. bts, _ := v.MarshalMsg(nil)
  51. b.ReportAllocs()
  52. b.SetBytes(int64(len(bts)))
  53. b.ResetTimer()
  54. for i := 0; i < b.N; i++ {
  55. _, err := v.UnmarshalMsg(bts)
  56. if err != nil {
  57. b.Fatal(err)
  58. }
  59. }
  60. }
  61. func TestEncodeDecodeActiveWorkerStat(t *testing.T) {
  62. v := ActiveWorkerStat{}
  63. var buf bytes.Buffer
  64. msgp.Encode(&buf, &v)
  65. m := v.Msgsize()
  66. if buf.Len() > m {
  67. t.Log("WARNING: TestEncodeDecodeActiveWorkerStat Msgsize() is inaccurate")
  68. }
  69. vn := ActiveWorkerStat{}
  70. err := msgp.Decode(&buf, &vn)
  71. if err != nil {
  72. t.Error(err)
  73. }
  74. buf.Reset()
  75. msgp.Encode(&buf, &v)
  76. err = msgp.NewReader(&buf).Skip()
  77. if err != nil {
  78. t.Error(err)
  79. }
  80. }
  81. func BenchmarkEncodeActiveWorkerStat(b *testing.B) {
  82. v := ActiveWorkerStat{}
  83. var buf bytes.Buffer
  84. msgp.Encode(&buf, &v)
  85. b.SetBytes(int64(buf.Len()))
  86. en := msgp.NewWriter(msgp.Nowhere)
  87. b.ReportAllocs()
  88. b.ResetTimer()
  89. for i := 0; i < b.N; i++ {
  90. v.EncodeMsg(en)
  91. }
  92. en.Flush()
  93. }
  94. func BenchmarkDecodeActiveWorkerStat(b *testing.B) {
  95. v := ActiveWorkerStat{}
  96. var buf bytes.Buffer
  97. msgp.Encode(&buf, &v)
  98. b.SetBytes(int64(buf.Len()))
  99. rd := msgp.NewEndlessReader(buf.Bytes(), b)
  100. dc := msgp.NewReader(rd)
  101. b.ReportAllocs()
  102. b.ResetTimer()
  103. for i := 0; i < b.N; i++ {
  104. err := v.DecodeMsg(dc)
  105. if err != nil {
  106. b.Fatal(err)
  107. }
  108. }
  109. }
  110. func TestMarshalUnmarshalInQueueMetric(t *testing.T) {
  111. v := InQueueMetric{}
  112. bts, err := v.MarshalMsg(nil)
  113. if err != nil {
  114. t.Fatal(err)
  115. }
  116. left, err := v.UnmarshalMsg(bts)
  117. if err != nil {
  118. t.Fatal(err)
  119. }
  120. if len(left) > 0 {
  121. t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
  122. }
  123. left, err = msgp.Skip(bts)
  124. if err != nil {
  125. t.Fatal(err)
  126. }
  127. if len(left) > 0 {
  128. t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
  129. }
  130. }
  131. func BenchmarkMarshalMsgInQueueMetric(b *testing.B) {
  132. v := InQueueMetric{}
  133. b.ReportAllocs()
  134. b.ResetTimer()
  135. for i := 0; i < b.N; i++ {
  136. v.MarshalMsg(nil)
  137. }
  138. }
  139. func BenchmarkAppendMsgInQueueMetric(b *testing.B) {
  140. v := InQueueMetric{}
  141. bts := make([]byte, 0, v.Msgsize())
  142. bts, _ = v.MarshalMsg(bts[0:0])
  143. b.SetBytes(int64(len(bts)))
  144. b.ReportAllocs()
  145. b.ResetTimer()
  146. for i := 0; i < b.N; i++ {
  147. bts, _ = v.MarshalMsg(bts[0:0])
  148. }
  149. }
  150. func BenchmarkUnmarshalInQueueMetric(b *testing.B) {
  151. v := InQueueMetric{}
  152. bts, _ := v.MarshalMsg(nil)
  153. b.ReportAllocs()
  154. b.SetBytes(int64(len(bts)))
  155. b.ResetTimer()
  156. for i := 0; i < b.N; i++ {
  157. _, err := v.UnmarshalMsg(bts)
  158. if err != nil {
  159. b.Fatal(err)
  160. }
  161. }
  162. }
  163. func TestEncodeDecodeInQueueMetric(t *testing.T) {
  164. v := InQueueMetric{}
  165. var buf bytes.Buffer
  166. msgp.Encode(&buf, &v)
  167. m := v.Msgsize()
  168. if buf.Len() > m {
  169. t.Log("WARNING: TestEncodeDecodeInQueueMetric Msgsize() is inaccurate")
  170. }
  171. vn := InQueueMetric{}
  172. err := msgp.Decode(&buf, &vn)
  173. if err != nil {
  174. t.Error(err)
  175. }
  176. buf.Reset()
  177. msgp.Encode(&buf, &v)
  178. err = msgp.NewReader(&buf).Skip()
  179. if err != nil {
  180. t.Error(err)
  181. }
  182. }
  183. func BenchmarkEncodeInQueueMetric(b *testing.B) {
  184. v := InQueueMetric{}
  185. var buf bytes.Buffer
  186. msgp.Encode(&buf, &v)
  187. b.SetBytes(int64(buf.Len()))
  188. en := msgp.NewWriter(msgp.Nowhere)
  189. b.ReportAllocs()
  190. b.ResetTimer()
  191. for i := 0; i < b.N; i++ {
  192. v.EncodeMsg(en)
  193. }
  194. en.Flush()
  195. }
  196. func BenchmarkDecodeInQueueMetric(b *testing.B) {
  197. v := InQueueMetric{}
  198. var buf bytes.Buffer
  199. msgp.Encode(&buf, &v)
  200. b.SetBytes(int64(buf.Len()))
  201. rd := msgp.NewEndlessReader(buf.Bytes(), b)
  202. dc := msgp.NewReader(rd)
  203. b.ReportAllocs()
  204. b.ResetTimer()
  205. for i := 0; i < b.N; i++ {
  206. err := v.DecodeMsg(dc)
  207. if err != nil {
  208. b.Fatal(err)
  209. }
  210. }
  211. }
  212. func TestMarshalUnmarshalInQueueStats(t *testing.T) {
  213. v := InQueueStats{}
  214. bts, err := v.MarshalMsg(nil)
  215. if err != nil {
  216. t.Fatal(err)
  217. }
  218. left, err := v.UnmarshalMsg(bts)
  219. if err != nil {
  220. t.Fatal(err)
  221. }
  222. if len(left) > 0 {
  223. t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
  224. }
  225. left, err = msgp.Skip(bts)
  226. if err != nil {
  227. t.Fatal(err)
  228. }
  229. if len(left) > 0 {
  230. t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
  231. }
  232. }
  233. func BenchmarkMarshalMsgInQueueStats(b *testing.B) {
  234. v := InQueueStats{}
  235. b.ReportAllocs()
  236. b.ResetTimer()
  237. for i := 0; i < b.N; i++ {
  238. v.MarshalMsg(nil)
  239. }
  240. }
  241. func BenchmarkAppendMsgInQueueStats(b *testing.B) {
  242. v := InQueueStats{}
  243. bts := make([]byte, 0, v.Msgsize())
  244. bts, _ = v.MarshalMsg(bts[0:0])
  245. b.SetBytes(int64(len(bts)))
  246. b.ReportAllocs()
  247. b.ResetTimer()
  248. for i := 0; i < b.N; i++ {
  249. bts, _ = v.MarshalMsg(bts[0:0])
  250. }
  251. }
  252. func BenchmarkUnmarshalInQueueStats(b *testing.B) {
  253. v := InQueueStats{}
  254. bts, _ := v.MarshalMsg(nil)
  255. b.ReportAllocs()
  256. b.SetBytes(int64(len(bts)))
  257. b.ResetTimer()
  258. for i := 0; i < b.N; i++ {
  259. _, err := v.UnmarshalMsg(bts)
  260. if err != nil {
  261. b.Fatal(err)
  262. }
  263. }
  264. }
  265. func TestEncodeDecodeInQueueStats(t *testing.T) {
  266. v := InQueueStats{}
  267. var buf bytes.Buffer
  268. msgp.Encode(&buf, &v)
  269. m := v.Msgsize()
  270. if buf.Len() > m {
  271. t.Log("WARNING: TestEncodeDecodeInQueueStats Msgsize() is inaccurate")
  272. }
  273. vn := InQueueStats{}
  274. err := msgp.Decode(&buf, &vn)
  275. if err != nil {
  276. t.Error(err)
  277. }
  278. buf.Reset()
  279. msgp.Encode(&buf, &v)
  280. err = msgp.NewReader(&buf).Skip()
  281. if err != nil {
  282. t.Error(err)
  283. }
  284. }
  285. func BenchmarkEncodeInQueueStats(b *testing.B) {
  286. v := InQueueStats{}
  287. var buf bytes.Buffer
  288. msgp.Encode(&buf, &v)
  289. b.SetBytes(int64(buf.Len()))
  290. en := msgp.NewWriter(msgp.Nowhere)
  291. b.ReportAllocs()
  292. b.ResetTimer()
  293. for i := 0; i < b.N; i++ {
  294. v.EncodeMsg(en)
  295. }
  296. en.Flush()
  297. }
  298. func BenchmarkDecodeInQueueStats(b *testing.B) {
  299. v := InQueueStats{}
  300. var buf bytes.Buffer
  301. msgp.Encode(&buf, &v)
  302. b.SetBytes(int64(buf.Len()))
  303. rd := msgp.NewEndlessReader(buf.Bytes(), b)
  304. dc := msgp.NewReader(rd)
  305. b.ReportAllocs()
  306. b.ResetTimer()
  307. for i := 0; i < b.N; i++ {
  308. err := v.DecodeMsg(dc)
  309. if err != nil {
  310. b.Fatal(err)
  311. }
  312. }
  313. }
  314. func TestMarshalUnmarshalProxyMetric(t *testing.T) {
  315. v := ProxyMetric{}
  316. bts, err := v.MarshalMsg(nil)
  317. if err != nil {
  318. t.Fatal(err)
  319. }
  320. left, err := v.UnmarshalMsg(bts)
  321. if err != nil {
  322. t.Fatal(err)
  323. }
  324. if len(left) > 0 {
  325. t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
  326. }
  327. left, err = msgp.Skip(bts)
  328. if err != nil {
  329. t.Fatal(err)
  330. }
  331. if len(left) > 0 {
  332. t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
  333. }
  334. }
  335. func BenchmarkMarshalMsgProxyMetric(b *testing.B) {
  336. v := ProxyMetric{}
  337. b.ReportAllocs()
  338. b.ResetTimer()
  339. for i := 0; i < b.N; i++ {
  340. v.MarshalMsg(nil)
  341. }
  342. }
  343. func BenchmarkAppendMsgProxyMetric(b *testing.B) {
  344. v := ProxyMetric{}
  345. bts := make([]byte, 0, v.Msgsize())
  346. bts, _ = v.MarshalMsg(bts[0:0])
  347. b.SetBytes(int64(len(bts)))
  348. b.ReportAllocs()
  349. b.ResetTimer()
  350. for i := 0; i < b.N; i++ {
  351. bts, _ = v.MarshalMsg(bts[0:0])
  352. }
  353. }
  354. func BenchmarkUnmarshalProxyMetric(b *testing.B) {
  355. v := ProxyMetric{}
  356. bts, _ := v.MarshalMsg(nil)
  357. b.ReportAllocs()
  358. b.SetBytes(int64(len(bts)))
  359. b.ResetTimer()
  360. for i := 0; i < b.N; i++ {
  361. _, err := v.UnmarshalMsg(bts)
  362. if err != nil {
  363. b.Fatal(err)
  364. }
  365. }
  366. }
  367. func TestEncodeDecodeProxyMetric(t *testing.T) {
  368. v := ProxyMetric{}
  369. var buf bytes.Buffer
  370. msgp.Encode(&buf, &v)
  371. m := v.Msgsize()
  372. if buf.Len() > m {
  373. t.Log("WARNING: TestEncodeDecodeProxyMetric Msgsize() is inaccurate")
  374. }
  375. vn := ProxyMetric{}
  376. err := msgp.Decode(&buf, &vn)
  377. if err != nil {
  378. t.Error(err)
  379. }
  380. buf.Reset()
  381. msgp.Encode(&buf, &v)
  382. err = msgp.NewReader(&buf).Skip()
  383. if err != nil {
  384. t.Error(err)
  385. }
  386. }
  387. func BenchmarkEncodeProxyMetric(b *testing.B) {
  388. v := ProxyMetric{}
  389. var buf bytes.Buffer
  390. msgp.Encode(&buf, &v)
  391. b.SetBytes(int64(buf.Len()))
  392. en := msgp.NewWriter(msgp.Nowhere)
  393. b.ReportAllocs()
  394. b.ResetTimer()
  395. for i := 0; i < b.N; i++ {
  396. v.EncodeMsg(en)
  397. }
  398. en.Flush()
  399. }
  400. func BenchmarkDecodeProxyMetric(b *testing.B) {
  401. v := ProxyMetric{}
  402. var buf bytes.Buffer
  403. msgp.Encode(&buf, &v)
  404. b.SetBytes(int64(buf.Len()))
  405. rd := msgp.NewEndlessReader(buf.Bytes(), b)
  406. dc := msgp.NewReader(rd)
  407. b.ReportAllocs()
  408. b.ResetTimer()
  409. for i := 0; i < b.N; i++ {
  410. err := v.DecodeMsg(dc)
  411. if err != nil {
  412. b.Fatal(err)
  413. }
  414. }
  415. }
  416. func TestMarshalUnmarshalQStat(t *testing.T) {
  417. v := QStat{}
  418. bts, err := v.MarshalMsg(nil)
  419. if err != nil {
  420. t.Fatal(err)
  421. }
  422. left, err := v.UnmarshalMsg(bts)
  423. if err != nil {
  424. t.Fatal(err)
  425. }
  426. if len(left) > 0 {
  427. t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
  428. }
  429. left, err = msgp.Skip(bts)
  430. if err != nil {
  431. t.Fatal(err)
  432. }
  433. if len(left) > 0 {
  434. t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
  435. }
  436. }
  437. func BenchmarkMarshalMsgQStat(b *testing.B) {
  438. v := QStat{}
  439. b.ReportAllocs()
  440. b.ResetTimer()
  441. for i := 0; i < b.N; i++ {
  442. v.MarshalMsg(nil)
  443. }
  444. }
  445. func BenchmarkAppendMsgQStat(b *testing.B) {
  446. v := QStat{}
  447. bts := make([]byte, 0, v.Msgsize())
  448. bts, _ = v.MarshalMsg(bts[0:0])
  449. b.SetBytes(int64(len(bts)))
  450. b.ReportAllocs()
  451. b.ResetTimer()
  452. for i := 0; i < b.N; i++ {
  453. bts, _ = v.MarshalMsg(bts[0:0])
  454. }
  455. }
  456. func BenchmarkUnmarshalQStat(b *testing.B) {
  457. v := QStat{}
  458. bts, _ := v.MarshalMsg(nil)
  459. b.ReportAllocs()
  460. b.SetBytes(int64(len(bts)))
  461. b.ResetTimer()
  462. for i := 0; i < b.N; i++ {
  463. _, err := v.UnmarshalMsg(bts)
  464. if err != nil {
  465. b.Fatal(err)
  466. }
  467. }
  468. }
  469. func TestEncodeDecodeQStat(t *testing.T) {
  470. v := QStat{}
  471. var buf bytes.Buffer
  472. msgp.Encode(&buf, &v)
  473. m := v.Msgsize()
  474. if buf.Len() > m {
  475. t.Log("WARNING: TestEncodeDecodeQStat Msgsize() is inaccurate")
  476. }
  477. vn := QStat{}
  478. err := msgp.Decode(&buf, &vn)
  479. if err != nil {
  480. t.Error(err)
  481. }
  482. buf.Reset()
  483. msgp.Encode(&buf, &v)
  484. err = msgp.NewReader(&buf).Skip()
  485. if err != nil {
  486. t.Error(err)
  487. }
  488. }
  489. func BenchmarkEncodeQStat(b *testing.B) {
  490. v := QStat{}
  491. var buf bytes.Buffer
  492. msgp.Encode(&buf, &v)
  493. b.SetBytes(int64(buf.Len()))
  494. en := msgp.NewWriter(msgp.Nowhere)
  495. b.ReportAllocs()
  496. b.ResetTimer()
  497. for i := 0; i < b.N; i++ {
  498. v.EncodeMsg(en)
  499. }
  500. en.Flush()
  501. }
  502. func BenchmarkDecodeQStat(b *testing.B) {
  503. v := QStat{}
  504. var buf bytes.Buffer
  505. msgp.Encode(&buf, &v)
  506. b.SetBytes(int64(buf.Len()))
  507. rd := msgp.NewEndlessReader(buf.Bytes(), b)
  508. dc := msgp.NewReader(rd)
  509. b.ReportAllocs()
  510. b.ResetTimer()
  511. for i := 0; i < b.N; i++ {
  512. err := v.DecodeMsg(dc)
  513. if err != nil {
  514. b.Fatal(err)
  515. }
  516. }
  517. }
  518. func TestMarshalUnmarshalReplicationMRFStats(t *testing.T) {
  519. v := ReplicationMRFStats{}
  520. bts, err := v.MarshalMsg(nil)
  521. if err != nil {
  522. t.Fatal(err)
  523. }
  524. left, err := v.UnmarshalMsg(bts)
  525. if err != nil {
  526. t.Fatal(err)
  527. }
  528. if len(left) > 0 {
  529. t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
  530. }
  531. left, err = msgp.Skip(bts)
  532. if err != nil {
  533. t.Fatal(err)
  534. }
  535. if len(left) > 0 {
  536. t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
  537. }
  538. }
  539. func BenchmarkMarshalMsgReplicationMRFStats(b *testing.B) {
  540. v := ReplicationMRFStats{}
  541. b.ReportAllocs()
  542. b.ResetTimer()
  543. for i := 0; i < b.N; i++ {
  544. v.MarshalMsg(nil)
  545. }
  546. }
  547. func BenchmarkAppendMsgReplicationMRFStats(b *testing.B) {
  548. v := ReplicationMRFStats{}
  549. bts := make([]byte, 0, v.Msgsize())
  550. bts, _ = v.MarshalMsg(bts[0:0])
  551. b.SetBytes(int64(len(bts)))
  552. b.ReportAllocs()
  553. b.ResetTimer()
  554. for i := 0; i < b.N; i++ {
  555. bts, _ = v.MarshalMsg(bts[0:0])
  556. }
  557. }
  558. func BenchmarkUnmarshalReplicationMRFStats(b *testing.B) {
  559. v := ReplicationMRFStats{}
  560. bts, _ := v.MarshalMsg(nil)
  561. b.ReportAllocs()
  562. b.SetBytes(int64(len(bts)))
  563. b.ResetTimer()
  564. for i := 0; i < b.N; i++ {
  565. _, err := v.UnmarshalMsg(bts)
  566. if err != nil {
  567. b.Fatal(err)
  568. }
  569. }
  570. }
  571. func TestEncodeDecodeReplicationMRFStats(t *testing.T) {
  572. v := ReplicationMRFStats{}
  573. var buf bytes.Buffer
  574. msgp.Encode(&buf, &v)
  575. m := v.Msgsize()
  576. if buf.Len() > m {
  577. t.Log("WARNING: TestEncodeDecodeReplicationMRFStats Msgsize() is inaccurate")
  578. }
  579. vn := ReplicationMRFStats{}
  580. err := msgp.Decode(&buf, &vn)
  581. if err != nil {
  582. t.Error(err)
  583. }
  584. buf.Reset()
  585. msgp.Encode(&buf, &v)
  586. err = msgp.NewReader(&buf).Skip()
  587. if err != nil {
  588. t.Error(err)
  589. }
  590. }
  591. func BenchmarkEncodeReplicationMRFStats(b *testing.B) {
  592. v := ReplicationMRFStats{}
  593. var buf bytes.Buffer
  594. msgp.Encode(&buf, &v)
  595. b.SetBytes(int64(buf.Len()))
  596. en := msgp.NewWriter(msgp.Nowhere)
  597. b.ReportAllocs()
  598. b.ResetTimer()
  599. for i := 0; i < b.N; i++ {
  600. v.EncodeMsg(en)
  601. }
  602. en.Flush()
  603. }
  604. func BenchmarkDecodeReplicationMRFStats(b *testing.B) {
  605. v := ReplicationMRFStats{}
  606. var buf bytes.Buffer
  607. msgp.Encode(&buf, &v)
  608. b.SetBytes(int64(buf.Len()))
  609. rd := msgp.NewEndlessReader(buf.Bytes(), b)
  610. dc := msgp.NewReader(rd)
  611. b.ReportAllocs()
  612. b.ResetTimer()
  613. for i := 0; i < b.N; i++ {
  614. err := v.DecodeMsg(dc)
  615. if err != nil {
  616. b.Fatal(err)
  617. }
  618. }
  619. }
  620. func TestMarshalUnmarshalSMA(t *testing.T) {
  621. v := SMA{}
  622. bts, err := v.MarshalMsg(nil)
  623. if err != nil {
  624. t.Fatal(err)
  625. }
  626. left, err := v.UnmarshalMsg(bts)
  627. if err != nil {
  628. t.Fatal(err)
  629. }
  630. if len(left) > 0 {
  631. t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
  632. }
  633. left, err = msgp.Skip(bts)
  634. if err != nil {
  635. t.Fatal(err)
  636. }
  637. if len(left) > 0 {
  638. t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
  639. }
  640. }
  641. func BenchmarkMarshalMsgSMA(b *testing.B) {
  642. v := SMA{}
  643. b.ReportAllocs()
  644. b.ResetTimer()
  645. for i := 0; i < b.N; i++ {
  646. v.MarshalMsg(nil)
  647. }
  648. }
  649. func BenchmarkAppendMsgSMA(b *testing.B) {
  650. v := SMA{}
  651. bts := make([]byte, 0, v.Msgsize())
  652. bts, _ = v.MarshalMsg(bts[0:0])
  653. b.SetBytes(int64(len(bts)))
  654. b.ReportAllocs()
  655. b.ResetTimer()
  656. for i := 0; i < b.N; i++ {
  657. bts, _ = v.MarshalMsg(bts[0:0])
  658. }
  659. }
  660. func BenchmarkUnmarshalSMA(b *testing.B) {
  661. v := SMA{}
  662. bts, _ := v.MarshalMsg(nil)
  663. b.ReportAllocs()
  664. b.SetBytes(int64(len(bts)))
  665. b.ResetTimer()
  666. for i := 0; i < b.N; i++ {
  667. _, err := v.UnmarshalMsg(bts)
  668. if err != nil {
  669. b.Fatal(err)
  670. }
  671. }
  672. }
  673. func TestEncodeDecodeSMA(t *testing.T) {
  674. v := SMA{}
  675. var buf bytes.Buffer
  676. msgp.Encode(&buf, &v)
  677. m := v.Msgsize()
  678. if buf.Len() > m {
  679. t.Log("WARNING: TestEncodeDecodeSMA Msgsize() is inaccurate")
  680. }
  681. vn := SMA{}
  682. err := msgp.Decode(&buf, &vn)
  683. if err != nil {
  684. t.Error(err)
  685. }
  686. buf.Reset()
  687. msgp.Encode(&buf, &v)
  688. err = msgp.NewReader(&buf).Skip()
  689. if err != nil {
  690. t.Error(err)
  691. }
  692. }
  693. func BenchmarkEncodeSMA(b *testing.B) {
  694. v := SMA{}
  695. var buf bytes.Buffer
  696. msgp.Encode(&buf, &v)
  697. b.SetBytes(int64(buf.Len()))
  698. en := msgp.NewWriter(msgp.Nowhere)
  699. b.ReportAllocs()
  700. b.ResetTimer()
  701. for i := 0; i < b.N; i++ {
  702. v.EncodeMsg(en)
  703. }
  704. en.Flush()
  705. }
  706. func BenchmarkDecodeSMA(b *testing.B) {
  707. v := SMA{}
  708. var buf bytes.Buffer
  709. msgp.Encode(&buf, &v)
  710. b.SetBytes(int64(buf.Len()))
  711. rd := msgp.NewEndlessReader(buf.Bytes(), b)
  712. dc := msgp.NewReader(rd)
  713. b.ReportAllocs()
  714. b.ResetTimer()
  715. for i := 0; i < b.N; i++ {
  716. err := v.DecodeMsg(dc)
  717. if err != nil {
  718. b.Fatal(err)
  719. }
  720. }
  721. }
  722. func TestMarshalUnmarshalXferStats(t *testing.T) {
  723. v := XferStats{}
  724. bts, err := v.MarshalMsg(nil)
  725. if err != nil {
  726. t.Fatal(err)
  727. }
  728. left, err := v.UnmarshalMsg(bts)
  729. if err != nil {
  730. t.Fatal(err)
  731. }
  732. if len(left) > 0 {
  733. t.Errorf("%d bytes left over after UnmarshalMsg(): %q", len(left), left)
  734. }
  735. left, err = msgp.Skip(bts)
  736. if err != nil {
  737. t.Fatal(err)
  738. }
  739. if len(left) > 0 {
  740. t.Errorf("%d bytes left over after Skip(): %q", len(left), left)
  741. }
  742. }
  743. func BenchmarkMarshalMsgXferStats(b *testing.B) {
  744. v := XferStats{}
  745. b.ReportAllocs()
  746. b.ResetTimer()
  747. for i := 0; i < b.N; i++ {
  748. v.MarshalMsg(nil)
  749. }
  750. }
  751. func BenchmarkAppendMsgXferStats(b *testing.B) {
  752. v := XferStats{}
  753. bts := make([]byte, 0, v.Msgsize())
  754. bts, _ = v.MarshalMsg(bts[0:0])
  755. b.SetBytes(int64(len(bts)))
  756. b.ReportAllocs()
  757. b.ResetTimer()
  758. for i := 0; i < b.N; i++ {
  759. bts, _ = v.MarshalMsg(bts[0:0])
  760. }
  761. }
  762. func BenchmarkUnmarshalXferStats(b *testing.B) {
  763. v := XferStats{}
  764. bts, _ := v.MarshalMsg(nil)
  765. b.ReportAllocs()
  766. b.SetBytes(int64(len(bts)))
  767. b.ResetTimer()
  768. for i := 0; i < b.N; i++ {
  769. _, err := v.UnmarshalMsg(bts)
  770. if err != nil {
  771. b.Fatal(err)
  772. }
  773. }
  774. }
  775. func TestEncodeDecodeXferStats(t *testing.T) {
  776. v := XferStats{}
  777. var buf bytes.Buffer
  778. msgp.Encode(&buf, &v)
  779. m := v.Msgsize()
  780. if buf.Len() > m {
  781. t.Log("WARNING: TestEncodeDecodeXferStats Msgsize() is inaccurate")
  782. }
  783. vn := XferStats{}
  784. err := msgp.Decode(&buf, &vn)
  785. if err != nil {
  786. t.Error(err)
  787. }
  788. buf.Reset()
  789. msgp.Encode(&buf, &v)
  790. err = msgp.NewReader(&buf).Skip()
  791. if err != nil {
  792. t.Error(err)
  793. }
  794. }
  795. func BenchmarkEncodeXferStats(b *testing.B) {
  796. v := XferStats{}
  797. var buf bytes.Buffer
  798. msgp.Encode(&buf, &v)
  799. b.SetBytes(int64(buf.Len()))
  800. en := msgp.NewWriter(msgp.Nowhere)
  801. b.ReportAllocs()
  802. b.ResetTimer()
  803. for i := 0; i < b.N; i++ {
  804. v.EncodeMsg(en)
  805. }
  806. en.Flush()
  807. }
  808. func BenchmarkDecodeXferStats(b *testing.B) {
  809. v := XferStats{}
  810. var buf bytes.Buffer
  811. msgp.Encode(&buf, &v)
  812. b.SetBytes(int64(buf.Len()))
  813. rd := msgp.NewEndlessReader(buf.Bytes(), b)
  814. dc := msgp.NewReader(rd)
  815. b.ReportAllocs()
  816. b.ResetTimer()
  817. for i := 0; i < b.N; i++ {
  818. err := v.DecodeMsg(dc)
  819. if err != nil {
  820. b.Fatal(err)
  821. }
  822. }
  823. }