diff --git a/copyright_header.txt b/copyright_header.txt new file mode 100644 index 000000000..69d8706bd --- /dev/null +++ b/copyright_header.txt @@ -0,0 +1,17 @@ +/* +Rating system designed to be used in VoIP Carriers World +Copyright (C) 2012 Radu Ioan Fericean + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see +*/ diff --git a/header.sh b/header.sh new file mode 100755 index 000000000..cbee07f5f --- /dev/null +++ b/header.sh @@ -0,0 +1,24 @@ +# check for arguments +if [ $# -ne 1 ] +then + echo "Error in $0 - Invalid Argument Count" + echo "Syntax: $0 input_file - copyright header file" + exit +fi + +# check for header file +infile=$1 +if [ ! -f $infile ] +then + echo "Input file [$infile] not found - Aborting" + exit +fi + +# inject header +for i in *.go +do + if ! grep -q Copyright $i + then + cat $infile $i >$i.new && mv $i.new $i + fi +done diff --git a/timespans/activationperiod.go b/timespans/activationperiod.go index 613e69e2d..20642268d 100644 --- a/timespans/activationperiod.go +++ b/timespans/activationperiod.go @@ -72,6 +72,7 @@ func (ap *ActivationPeriod) restore(input string) { elements := strings.Split(input, ";") unixNano, _ := strconv.ParseInt(elements[0], 10, 64) ap.ActivationTime = time.Unix(0, unixNano).In(time.UTC) + ap.Intervals = make([]*Interval, 0) for _, is := range elements[1 : len(elements)-1] { i := &Interval{} ise := strings.Split(is, "|") diff --git a/timespans/activationperiod_test.go b/timespans/activationperiod_test.go index e30fef9a2..4efdab981 100644 --- a/timespans/activationperiod_test.go +++ b/timespans/activationperiod_test.go @@ -74,9 +74,30 @@ func TestApStoreRestore(t *testing.T) { } } +/**************************** Benchmarks *************************************/ + func BenchmarkActivationPeriodRestore(b *testing.B) { ap := ActivationPeriod{} for i := 0; i < b.N; i++ { ap.restore("1328106601;2|1|3,4|14:30:00|15:00:00|0|0|0|0;") } } + +func BenchmarkActivationPeriodStoreRestore(b *testing.B) { + b.StopTimer() + d := time.Date(2012, time.February, 1, 14, 30, 1, 0, time.UTC) + i := &Interval{Month: time.February, + MonthDay: 1, + WeekDays: []time.Weekday{time.Wednesday, time.Thursday}, + StartTime: "14:30:00", + EndTime: "15:00:00"} + ap := &ActivationPeriod{ActivationTime: d} + ap.AddInterval(i) + + ap1 := ActivationPeriod{} + b.StartTimer() + for i := 0; i < b.N; i++ { + result := ap.store() + ap1.restore(result) + } +} diff --git a/timespans/test.kch b/timespans/test.kch index 99f1e2ebf..3edb68d9b 100644 Binary files a/timespans/test.kch and b/timespans/test.kch differ