From f136f1e67dda4aa0003138a0b43ab402469d4042 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 18 Dec 2013 15:27:46 +0200 Subject: [PATCH 1/4] more statistics --- engine/loader_csv.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/engine/loader_csv.go b/engine/loader_csv.go index 004ed7906..d45e67227 100644 --- a/engine/loader_csv.go +++ b/engine/loader_csv.go @@ -97,6 +97,7 @@ func openStringCSVReader(data string, comma rune, nrFields int) (csvReader *csv. } func (csvr *CSVReader) ShowStatistics() { + // destinations destCount := len(csvr.destinations) log.Print("Destinations: ", destCount) prefixDist := make(map[int]int, 50) @@ -110,6 +111,34 @@ func (csvr *CSVReader) ShowStatistics() { for k, v := range prefixDist { log.Printf("%d: %d", k, v) } + // rating plans + rplCount := len(csvr.ratingPlans) + log.Print("Rating plans: ", rplCount) + destRatesDist := make(map[int]int, 50) + destRatesCount := 0 + for _, rpl := range csvr.ratingPlans { + destRatesDist[len(rpl.DestinationRates)] += 1 + destRatesCount += len(rpl.DestinationRates) + } + log.Print("Avg Destination Rates: ", destRatesCount/rplCount) + log.Print("Destination Rates distribution:") + for k, v := range destRatesDist { + log.Printf("%d: %d", k, v) + } + // rating profiles + rpfCount := len(csvr.ratingProfiles) + log.Print("Rating profiles: ", rpfCount) + activDist := make(map[int]int, 50) + activCount := 0 + for _, rpf := range csvr.ratingProfiles { + activDist[len(rpf.RatingPlanActivations)] += 1 + activCount += len(rpf.RatingPlanActivations) + } + log.Print("Avg Activations: ", activCount/rpfCount) + log.Print("Activation distribution:") + for k, v := range activDist { + log.Printf("%d: %d", k, v) + } } func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { From 18273a920e69a9df6ad1e6599296ca196159145a Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 18 Dec 2013 15:31:20 +0200 Subject: [PATCH 2/4] accounting stats --- engine/loader_csv.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/engine/loader_csv.go b/engine/loader_csv.go index d45e67227..380dd443e 100644 --- a/engine/loader_csv.go +++ b/engine/loader_csv.go @@ -139,6 +139,12 @@ func (csvr *CSVReader) ShowStatistics() { for k, v := range activDist { log.Printf("%d: %d", k, v) } + // actions + log.Print("Actions: ", len(csvr.actions)) + // action timings + log.Print("Action timings: ", len(csvr.actionsTimings)) + // account actions + log.Print("Account actions: ", len(csvr.accountActions)) } func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error) { From 6d543f5d860568d66f584be210c9500326273ae0 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 18 Dec 2013 15:37:19 +0200 Subject: [PATCH 3/4] db loader stats --- engine/loader_db.go | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/engine/loader_db.go b/engine/loader_db.go index 23dbbdb54..ad7c3993f 100644 --- a/engine/loader_db.go +++ b/engine/loader_db.go @@ -55,7 +55,56 @@ func NewDbReader(storDB LoadStorage, storage DataStorage, tpid string) *DbReader return c } +// dis method is code duplication from csv loader func (dbr *DbReader) ShowStatistics() { + // destinations + destCount := len(dbr.destinations) + log.Print("Destinations: ", destCount) + prefixDist := make(map[int]int, 50) + prefixCount := 0 + for _, d := range dbr.destinations { + prefixDist[len(d.Prefixes)] += 1 + prefixCount += len(d.Prefixes) + } + log.Print("Avg Prefixes: ", prefixCount/destCount) + log.Print("Prefixes distribution:") + for k, v := range prefixDist { + log.Printf("%d: %d", k, v) + } + // rating plans + rplCount := len(dbr.ratingPlans) + log.Print("Rating plans: ", rplCount) + destRatesDist := make(map[int]int, 50) + destRatesCount := 0 + for _, rpl := range dbr.ratingPlans { + destRatesDist[len(rpl.DestinationRates)] += 1 + destRatesCount += len(rpl.DestinationRates) + } + log.Print("Avg Destination Rates: ", destRatesCount/rplCount) + log.Print("Destination Rates distribution:") + for k, v := range destRatesDist { + log.Printf("%d: %d", k, v) + } + // rating profiles + rpfCount := len(dbr.ratingProfiles) + log.Print("Rating profiles: ", rpfCount) + activDist := make(map[int]int, 50) + activCount := 0 + for _, rpf := range dbr.ratingProfiles { + activDist[len(rpf.RatingPlanActivations)] += 1 + activCount += len(rpf.RatingPlanActivations) + } + log.Print("Avg Activations: ", activCount/rpfCount) + log.Print("Activation distribution:") + for k, v := range activDist { + log.Printf("%d: %d", k, v) + } + // actions + log.Print("Actions: ", len(dbr.actions)) + // action timings + log.Print("Action timings: ", len(dbr.actionsTimings)) + // account actions + log.Print("Account actions: ", len(dbr.accountActions)) } func (dbr *DbReader) WriteToDatabase(flush, verbose bool) (err error) { From f7d7a34c17c1476a61836613fd66de1caa075158 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 18 Dec 2013 15:38:04 +0200 Subject: [PATCH 4/4] typo --- engine/loader_db.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/loader_db.go b/engine/loader_db.go index ad7c3993f..781c3bef7 100644 --- a/engine/loader_db.go +++ b/engine/loader_db.go @@ -55,7 +55,7 @@ func NewDbReader(storDB LoadStorage, storage DataStorage, tpid string) *DbReader return c } -// dis method is code duplication from csv loader +// FIXME: this method is code duplication from csv loader func (dbr *DbReader) ShowStatistics() { // destinations destCount := len(dbr.destinations)