func init() { revel.Filters = []revel.Filter{ revel.RouterFilter, revel.ParamsFilter, revel.ActionInvoker, } revel.OnAppStart(func() { runtime.GOMAXPROCS(runtime.NumCPU()) db.Init() qbs.ChangePoolSize(MaxConnectionCount) }) }
func init() { st := NewSuite("qbs") st.InitF = func() { st.AddBenchmark("Insert", 2000*ORM_MULTI, QbsInsert) st.AddBenchmark("MultiInsert 100 row", 500*ORM_MULTI, QbsInsertMulti) st.AddBenchmark("Update", 2000*ORM_MULTI, QbsUpdate) st.AddBenchmark("Read", 4000*ORM_MULTI, QbsRead) st.AddBenchmark("MultiRead limit 100", 2000*ORM_MULTI, QbsReadSlice) qbs.Register("mysql", ORM_SOURCE, "model", qbs.NewMysql()) qbs.ChangePoolSize(ORM_MAX_IDLE) qbs.SetConnectionLimit(ORM_MAX_CONN, true) qo, _ = qbs.GetQbs() } }
func InitQbs(maxConn int) { var ( found bool driver, spec string ) if driver, found = revel.Config.String("db.driver"); !found { revel.ERROR.Fatal("No db.driver found.") } if spec, found = revel.Config.String("db.spec"); !found { revel.ERROR.Fatal("No db.spec found.") } // QBS uses snake case by default; override the name convention. qbs.ColumnNameToFieldName = noConvert qbs.FieldNameToColumnName = noConvert qbs.TableNameToStructName = noConvert qbs.StructNameToTableName = noConvert qbs.Register(driver, spec, "", qbs.NewMysql()) qbs.ChangePoolSize(maxConn) }