VOL-1175: Added proxy CRUD for new data model
Change-Id: Ie218a2567746d87a951f23aa6b774b2f01541cf9
diff --git a/db/model/profiling.go b/db/model/profiling.go
new file mode 100644
index 0000000..9d13d5a
--- /dev/null
+++ b/db/model/profiling.go
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+
+ * http://www.apache.org/licenses/LICENSE-2.0
+
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package model
+
+import (
+ "sync"
+ "github.com/opencord/voltha-go/common/log"
+)
+
+type profiling struct {
+ DatabaseRetrieveTime float64
+ DatabaseRetrieveCount int
+ InMemoryModelTime float64
+ InMemoryModelCount int
+ InMemoryProcessTime float64
+ DatabaseStoreTime float64
+}
+
+var profiling_instance *profiling
+var profiling_once sync.Once
+
+func GetProfiling() *profiling {
+ profiling_once.Do(func() {
+ profiling_instance = &profiling{}
+ })
+ return profiling_instance
+}
+
+func (p *profiling) AddToDatabaseRetrieveTime(period float64) {
+ p.DatabaseRetrieveTime += period
+ p.DatabaseRetrieveCount += 1
+}
+func (p *profiling) AddToInMemoryModelTime(period float64) {
+ p.InMemoryModelTime += period
+ p.InMemoryModelCount += 1
+}
+func (p *profiling) AddToInMemoryProcessTime(period float64) {
+ p.InMemoryProcessTime += period
+}
+func (p *profiling) AddToDatabaseStoreTime(period float64) {
+ p.DatabaseStoreTime += period
+}
+
+func (p *profiling) Report() {
+ log.Infof("[ Profiling Report ]")
+ log.Infof("Database Retrieval : %f", p.DatabaseRetrieveTime)
+ log.Infof("Database Retrieval Count : %d", p.DatabaseRetrieveCount)
+ log.Infof("Avg Database Retrieval : %f", p.DatabaseRetrieveTime/float64(p.DatabaseRetrieveCount))
+ log.Infof("In-Memory Modeling : %f", p.InMemoryModelTime)
+ log.Infof("In-Memory Modeling Count: %d", p.InMemoryModelCount)
+ log.Infof("Avg In-Memory Modeling : %f", p.InMemoryModelTime/float64(p.InMemoryModelCount))
+
+}