From ea18014aa62ab7de47d63b4d123d52230eb96c53 Mon Sep 17 00:00:00 2001 From: Paul J R Date: Mon, 16 Nov 2009 02:30:03 +1100 Subject: [PATCH] table creation, random data and need some more stuff --- src/benchcontroller.go | 23 ++++++++++-- src/dbconnector.go | 94 +++++++++++++++++++++++++++++++++-------------- src/makeit | 3 +- src/webconnector.go | 3 ++ 4 files changed, 90 insertions(+), 33 deletions(-) mode change 100755 => 100644 src/makeit diff --git a/src/benchcontroller.go b/src/benchcontroller.go index 5370173..21150e1 100644 --- a/src/benchcontroller.go +++ b/src/benchcontroller.go @@ -3,9 +3,8 @@ package benchcontroller import ( - //"./dbconnector"; + "./dbconnector"; "fmt"; - "time"; "strings"; "strconv"; "os"; @@ -32,7 +31,6 @@ func CreateController()(contConfig *BenchControllerConfig) func MainLoop(conf *BenchControllerConfig, commInChan chan string, commOutChan chan string) { for { - time.Sleep(1000000000); i := <-commInChan; fmt.Printf("coms: %s\n", i); @@ -62,9 +60,26 @@ func MainLoop(conf *BenchControllerConfig, commInChan chan string, commOutChan c conf.dbpass = calls[4]; conf.dbname = calls[5]; - case "asdf": + case "begin": // get ready to bench - start the clients os.Stdout.WriteString("ready clients\n"); + + comchan := make(chan int); + var cont bool; + + + go dbconnector.DBSetup("mysql", conf.dbhost, conf.dbuser, conf.dbpass, conf.dbname, conf.datamult, comchan); + cont=true; + + for cont{ + val := <- comchan; + fmt.Printf("val: %d\n", val); + if val == 100 { + cont = false; + } + } + + os.Stdout.WriteString("ok, im done\n"); case "qwer": // start the clients os.Stdout.WriteString("start clients\n"); diff --git a/src/dbconnector.go b/src/dbconnector.go index e09ebe9..83dc649 100644 --- a/src/dbconnector.go +++ b/src/dbconnector.go @@ -1,10 +1,39 @@ // um yes... its a db connector package dbconnector +import ( + "./dbibridge"; + "time"; + "rand"; +) + type DBConnector struct { // err, yes } + +func CreateRandomText(len int) (str string) +{ + buf := make([]byte, len+2); + + rand.Seed(time.Nanoseconds()); + + for i:=0; i