123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- package main
- import (
- "runtime"
- "testing"
- )
- var symbols = []string{
- "sc",
- "btc",
- "bty",
- "eth",
- "etc",
- "zec",
- "bts",
- "ltc",
- "bcc",
- "nycc",
- "wtc",
- }
- var periods = []string{
- "M1",
- "M5",
- "M15",
- "M30",
- "H1",
- "H2",
- "H4",
- "D1",
- "W1",
- "MN1",
- }
- func BenchmarkGetData(b *testing.B) {
- runtime.GOMAXPROCS(runtime.NumCPU())
- conf, err := readConf()
- if err != nil {
- b.Fatal("readConf", err)
- } else {
- *saddr1 = conf.Saddr1
- *saddr2 = conf.Saddr2
- *saddr3 = conf.Saddr3
- *saddr4 = conf.Saddr4
- }
- err = connectServer()
- if err != nil {
- b.Fatal("connect server", err)
- }
- resCh := make(chan int)
- for i := 0; i < b.N; i++ {
- go func() {
- for _, symbol := range symbols {
- for _, period := range periods {
- _, err := getData(symbol, period, "init", "100", "", "jQuery112406248373254640218_1472016715089", "0", "0", K_STYLE)
- if err != nil {
- b.Error(err)
- }
- }
- }
- resCh <- 1
- }()
- }
- for i := 0; i < b.N; i++ {
- <-resCh
- }
- }
|