tidb size 源码
tidb size 代码
文件路径:/util/size/size.go
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package size
import "unsafe"
const (
// KB is the kilobytes.
KB = uint64(1024)
// MB is the megabytes.
MB = KB * 1024
// GB is the gigabytes.
GB = MB * 1024
// TB is the terabytes.
TB = GB * 1024
// PB is the petabytes.
PB = TB * 1024
)
// below constants are the size of commonly used types, for memory trace
const (
// SizeOfSlice is the memory itself used, excludes the elements' memory
SizeOfSlice = int64(unsafe.Sizeof(*new([]int)))
// SizeOfByte is the memory each byte occupied
SizeOfByte = int64(unsafe.Sizeof(*new(byte)))
// SizeOfString is the memory string itself occupied
SizeOfString = int64(unsafe.Sizeof(*new(string)))
// SizeOfBool is the memory each bool occupied
SizeOfBool = int64(unsafe.Sizeof(*new(bool)))
// SizeOfPointer is the memory each pointer occupied
SizeOfPointer = int64(unsafe.Sizeof(new(int)))
// SizeOfInterface is the memory each interface occupied, exclude the real type memory usage
SizeOfInterface = int64(unsafe.Sizeof(*new(interface{})))
// SizeOfFloat64 is the memory each float64 occupied
SizeOfFloat64 = int64(unsafe.Sizeof(*new(float64)))
// SizeOfUint64 is the memory each uint64 occupied
SizeOfUint64 = int64(unsafe.Sizeof(*new(uint64)))
// SizeOfInt32 is the memory each int32 occupied
SizeOfInt32 = int64(unsafe.Sizeof(*new(int32)))
// SizeOfInt is the memory each int occupied
SizeOfInt = int64(unsafe.Sizeof(*new(int)))
// SizeOfUint8 is the memory each uint8 occupied
SizeOfUint8 = int64(unsafe.Sizeof(*new(uint8)))
)
相关信息
相关文章
0
赞
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦