objects structure
This commit is contained in:
parent
9c7006dcea
commit
914177d440
5 changed files with 117 additions and 113 deletions
|
@ -4,15 +4,16 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
// "gopkg.in/mgo.v2"
|
||||
// "gopkg.in/mgo.v2/bson"
|
||||
"log"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/mikif70/pidlib"
|
||||
)
|
||||
|
||||
const (
|
||||
_VERSION = "v1.3.3"
|
||||
_VERSION = "v1.3.4"
|
||||
_tformat = "2006-01-02"
|
||||
_24h = (time.Hour * 23) + (time.Minute * 59) + (time.Second * 59)
|
||||
_10m = (time.Minute * 10)
|
||||
|
@ -29,16 +30,11 @@ var (
|
|||
Batch: 10000,
|
||||
}
|
||||
|
||||
loop []bool
|
||||
wg sync.WaitGroup
|
||||
|
||||
dbs = Dbs{}
|
||||
|
||||
idb = InfluxdbOutput{
|
||||
CountTOT: 0,
|
||||
CountOK: 0,
|
||||
Insert: 0,
|
||||
Find: 0,
|
||||
}
|
||||
idb *InfluxdbOutput
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -69,7 +65,8 @@ func main() {
|
|||
|
||||
log.SetOutput(fs)
|
||||
|
||||
pid.Write(true)
|
||||
pid := pidlib.New()
|
||||
pid.Write()
|
||||
defer pid.Remove()
|
||||
|
||||
start := time.Now()
|
||||
|
@ -86,57 +83,35 @@ func main() {
|
|||
os.Exit(-1)
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
//fmt.Printf("Start %+v\n\r", y)
|
||||
|
||||
// var ys []time.Time
|
||||
// var ye []time.Time
|
||||
var ys time.Time
|
||||
var ye time.Time
|
||||
|
||||
// if opts.Duration <= (time.Hour * 24) {
|
||||
ys = time.Date(y.Year(), y.Month(), y.Day(), 0, 0, 0, 0, time.UTC)
|
||||
ye = ys.Add(opts.Duration)
|
||||
|
||||
/*
|
||||
} else {
|
||||
for i := 0; i <= int(opts.Duration/(time.Hour*24)); i++ {
|
||||
yt := y.Add(time.Hour * time.Duration(24*i))
|
||||
if opts.Debug {
|
||||
fmt.Println(i)
|
||||
fmt.Println(yt)
|
||||
}
|
||||
ys = append(ys, time.Date(yt.Year(), yt.Month(), yt.Day(), 0, 0, 0, 0, time.UTC))
|
||||
ye = append(ye, ys[i].Add(_24h))
|
||||
}
|
||||
}
|
||||
*/
|
||||
idb = Influxdb(start, ys)
|
||||
|
||||
// DEBUG
|
||||
if opts.Debug {
|
||||
fmt.Printf("Start: %+v, Stop: %+v\n\r", ys, ye)
|
||||
}
|
||||
|
||||
// for i := range ys {
|
||||
|
||||
pStart := time.Now()
|
||||
|
||||
// aggregate(ys[i], ye[i])
|
||||
aggregate(ys, ye)
|
||||
agg := Consolidate(ys, ye)
|
||||
agg.Start()
|
||||
|
||||
fmt.Printf("Stop %s: %s\n", ys, time.Since(pStart))
|
||||
log.Printf("Stop %s: %s\n", ys, time.Since(pStart))
|
||||
|
||||
// fmt.Printf("Stop %s: %s\n", ys[i], time.Since(pStart))
|
||||
// log.Printf("Stop %s: %s\n", ys[i], time.Since(pStart))
|
||||
// }
|
||||
|
||||
idb.Stop = time.Since(start)
|
||||
|
||||
fmt.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", idb.CountOK, idb.CountTOT, idb.Stop)
|
||||
log.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", idb.CountOK, idb.CountTOT, idb.Stop)
|
||||
idb.InsUsers = agg.Verify()
|
||||
|
||||
fmt.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", idb.InsUsers, idb.TotUsers, idb.Stop)
|
||||
log.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", idb.InsUsers, idb.TotUsers, idb.Stop)
|
||||
|
||||
if opts.Influxdb != "" {
|
||||
writeStats(start, ys)
|
||||
idb.writeStats()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue