featurebase/debugstats/stats_test.go
reesporte 4c53f86e82 removed license from each go file
i used this script, a little clunky but it got the job done

```bash
for file in `find . -type f -print | grep '\.go'`; do
    sed '1,/^\/\/ limitations under the License.$/d' $file > $file.tmp;
    result=`cat $file.tmp`
    if [[ result != "" ]]; then
        gofmt $file.tmp &> /dev/null;
        if [[ $? == 0 ]]; then
            mv $file.tmp $file && gofmt -w $file;
        else
            rm $file.tmp;
        fi
    else
        rm $file.tmp;
    fi
done
```
2021-12-10 09:17:17 -06:00

40 lines
622 B
Go

package debugstats
import (
"fmt"
"testing"
"time"
)
func TestCallStats(t *testing.T) {
callStats := NewCallStats()
for j := 0; j < 4; j++ {
t0 := time.Now()
doOperation0()
callStats.Add("op0", time.Since(t0))
t1 := time.Now()
doOperation1()
callStats.Add("op1", time.Since(t1))
t2 := time.Now()
doOperation2()
callStats.Add("op2", time.Since(t2))
}
fmt.Printf("report = \n%v\n", callStats.Report("test"))
}
func doOperation0() {
time.Sleep(50 * time.Millisecond)
}
func doOperation1() {
time.Sleep(100 * time.Millisecond)
}
func doOperation2() {
time.Sleep(200 * time.Millisecond)
}