From 0bd20b3a22ad879a9bf89bfcf379a8f823b883c9 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Wed, 29 Feb 2012 14:35:28 +0200 Subject: [PATCH] added copyright addergit st --- copyright_header.txt | 17 +++++++++++++++++ header.sh | 24 ++++++++++++++++++++++++ timespans/activationperiod.go | 1 + timespans/activationperiod_test.go | 21 +++++++++++++++++++++ timespans/test.kch | Bin 6298936 -> 6299032 bytes 5 files changed, 63 insertions(+) create mode 100644 copyright_header.txt create mode 100755 header.sh 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 99f1e2ebf2990f1e480089ba23b5fdff6dfcc905..3edb68d9bb492ae54d65c00391fb483259129c97 100644 GIT binary patch delta 687 zcmbW!O)mpM7zglf7ttzp5ky^3ucb5F?zVQlY`C~IUh18)q$?U>WwlOw(1Y~gqP?ud zfyB*C(q_H%BlsLHLgE|vx0=wanfzuZd1fZhGxPX-#$LUgv6p?0W?QK#omXjkPMHF= z?`AW(tQ}Y@m#w+EU~YdSX}KUXv75|S!~srd02eeull2vG7v0SL-vj3|Q;_Y^Y+C;B z>b;$HvDXiDawg+{>V_WhLND||KMcSi41o`ZVFdg@fC2{r2m%iRgdhx~Ac6#AFb)$i zY5AYz;+pkw+&wk(pBnIBclnI=HVbnw4+{{5MOcDmSbx5lhJ5Y5}j)r5^(U#C@d`~<{YPzbcM=MRT_pWbuA>swBEaGR}Nt;3vwJSh;aO!%ax z7BwCOqo{S4?zzXmPM(%27cZ&Jh#4%<2mLSrgGMuAty;O~_CSGhWy(jjJni(>7%>_{ z;q^^btc-yR#$f{7FbPvI4Kpwcb1)AgNI<{?3*ZGG_+b$OumsBxgcVqY5Ud$ug;ryo z?2d=}{8E+r7Hq=~>_QawU>^?P5RM=Q$8Z9t5Qj5Esh?YXF8=3_ev5hIB6Xd*krSB& zk))s$Y*ixZAv+t^U+l~^S`*smdwrPBW|Z5khv;Dk^V@2s_P)uROe