cubefs

Форк
0
/
statistic_test.go 
47 строк · 1.3 Кб
1
// Copyright 2022 The CubeFS Authors.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
// implied. See the License for the specific language governing
13
// permissions and limitations under the License.
14

15
package stat
16

17
import (
18
	"os"
19
	"path"
20
	"testing"
21
	"time"
22

23
	"github.com/cubefs/cubefs/util/errors"
24
)
25

26
func TestStatistic(t *testing.T) {
27
	DefaultStatInterval = 1 * time.Second
28

29
	statLogPath := "./"
30
	statLogSize := 20000000
31
	statLogModule := "TestStatistic"
32
	timeOutUs := [MaxTimeoutLevel]uint32{100000, 500000, 1000000}
33

34
	_, err := NewStatistic(statLogPath, statLogModule, int64(statLogSize), timeOutUs, true)
35
	if err != nil {
36
		t.Fatal(err)
37
	}
38
	defer os.RemoveAll(path.Join(statLogPath, statLogModule))
39
	defer ClearStat()
40

41
	bgTime := BeginStat()
42
	EndStat("test1", nil, bgTime, 1)
43
	time.Sleep(time.Second)
44
	err = errors.New("EIO")
45
	EndStat("test2", err, bgTime, 100)
46
	time.Sleep(3 * time.Second)
47
}
48

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.