mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/encoding: add vm_zstd_block_{compress|decompress}_calls_total
for determining the number CompressZSTD / DecompressZSTD calls
This commit is contained in:
parent
2eb3602d61
commit
6b0ae332f8
1 changed files with 5 additions and 0 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
//
|
//
|
||||||
// The given compressLevel is used for the compression.
|
// The given compressLevel is used for the compression.
|
||||||
func CompressZSTDLevel(dst, src []byte, compressLevel int) []byte {
|
func CompressZSTDLevel(dst, src []byte, compressLevel int) []byte {
|
||||||
|
compressCalls.Inc()
|
||||||
originalBytes.Add(len(src))
|
originalBytes.Add(len(src))
|
||||||
dstLen := len(dst)
|
dstLen := len(dst)
|
||||||
dst = gozstd.CompressLevel(dst, src, compressLevel)
|
dst = gozstd.CompressLevel(dst, src, compressLevel)
|
||||||
|
@ -20,10 +21,14 @@ func CompressZSTDLevel(dst, src []byte, compressLevel int) []byte {
|
||||||
// DecompressZSTD decompresses src, appends the result to dst and returns
|
// DecompressZSTD decompresses src, appends the result to dst and returns
|
||||||
// the appended dst.
|
// the appended dst.
|
||||||
func DecompressZSTD(dst, src []byte) ([]byte, error) {
|
func DecompressZSTD(dst, src []byte) ([]byte, error) {
|
||||||
|
decompressCalls.Inc()
|
||||||
return gozstd.Decompress(dst, src)
|
return gozstd.Decompress(dst, src)
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
compressCalls = metrics.NewCounter(`vm_zstd_block_compress_calls_total`)
|
||||||
|
decompressCalls = metrics.NewCounter(`vm_zstd_block_decompress_calls_total`)
|
||||||
|
|
||||||
originalBytes = metrics.NewCounter(`vm_zstd_block_original_bytes_total`)
|
originalBytes = metrics.NewCounter(`vm_zstd_block_original_bytes_total`)
|
||||||
compressedBytes = metrics.NewCounter(`vm_zstd_block_compressed_bytes_total`)
|
compressedBytes = metrics.NewCounter(`vm_zstd_block_compressed_bytes_total`)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue