cubefs

Форк
0
/
stream_time.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 access
16

17
import (
18
	"fmt"
19
	"sync/atomic"
20
	"time"
21
)
22

23
type timeReadWrite struct {
24
	a int64 // alloc buffer
25
	r int64 // PUT: read from client,  GET: read from blobnode
26
	w int64 // PUT: write to blobnode, GET: write to client
27
}
28

29
func (t *timeReadWrite) IncA(dur time.Duration) {
30
	atomic.AddInt64(&t.a, int64(dur))
31
}
32

33
func (t *timeReadWrite) IncR(dur time.Duration) {
34
	atomic.AddInt64(&t.r, int64(dur))
35
}
36

37
func (t *timeReadWrite) IncW(dur time.Duration) {
38
	atomic.AddInt64(&t.w, int64(dur))
39
}
40

41
// String within milliseconds
42
func (t *timeReadWrite) String() string {
43
	a := atomic.LoadInt64(&t.a) / 1e6
44
	r := atomic.LoadInt64(&t.r) / 1e6
45
	w := atomic.LoadInt64(&t.w) / 1e6
46
	return fmt.Sprintf("a_%d_r_%d_w_%d", a, r, w)
47
}
48

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

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

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

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