v1_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package tests
  4. import (
  5. "fmt"
  6. "net"
  7. "testing"
  8. jsoniter "github.com/json-iterator/go"
  9. )
  10. var json = jsoniter.ConfigCompatibleWithStandardLibrary
  11. func Test_DustData(t *testing.T) {
  12. data := "##$$$$ST=32;CN=2031;PW=123456;MN=yc;SK=ACE41F3D035D1F21EF16B96BFEDA418B;CP=&&DataTime=20200825094100;PM10-Avg=68.5,PM10-Flag=T;T01-Avg=31.1,T01-Flag=N;B03-Avg=18.1,B03-Flag=P;H01-Avg=50.3,H01-Flag=N;W01-Avg=231.1,W01-Flag=N;W02-Avg=2.4,W02-Flag=N;R01-Avg=231.1,R01-Flag=N;P01-Avg=101.1,P01-Flag=N;&&@@@@\r\n"
  13. conn, err := net.Dial("tcp", "47.108.135.38:11003")
  14. if err != nil {
  15. fmt.Println("connet err:", err)
  16. }
  17. conn.Write([]byte(data))
  18. //conn.Write([]byte(data))
  19. //conn.Write([]byte(data))
  20. conn.Close()
  21. }
  22. /*
  23. func Benchmark_DustData(t *testing.B) {
  24. conn, err := net.Dial("tcp", "47.108.135.38:11003")
  25. if err != nil {
  26. fmt.Println("connet err:", err)
  27. }
  28. dataFormart := "##$$$$ST=32;CN=2061;PW=123456;MN=yc;SK=ACE41F3D035D1F21EF16B96BFEDA418B;CP=&&DataTime=%d;PM10-Avg=68.5,PM10-Flag=T;T01-Avg=31.1,T01-Flag=N;B03-Avg=18.1,B03-Flag=P;H01-Avg=50.3,H01-Flag=N;W01-Avg=231.1,W01-Flag=N;W02-Avg=2.4,W02-Flag=N;R01-Avg=231.1,R01-Flag=N;P01-Avg=101.1,P01-Flag=N;&&@@@@\r\n"
  29. start := 20200808094101
  30. for i := 0; i < 100000; i++ {
  31. data := fmt.Sprintf(dataFormart, start+i)
  32. conn.Write([]byte(data))
  33. }
  34. conn.Close()
  35. }
  36. */