mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 23:51:25 +08:00
feat: report worker system information to the master
This commit is contained in:
@@ -3,9 +3,11 @@ package builtin
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"encoding/csv"
|
||||
builtinJSON "encoding/json"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -505,6 +507,42 @@ func Bytes2File(data []byte, filename string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func Float32ToByte(v float32) []byte {
|
||||
bits := math.Float32bits(v)
|
||||
bytes := make([]byte, 4)
|
||||
binary.LittleEndian.PutUint32(bytes, bits)
|
||||
return bytes
|
||||
}
|
||||
|
||||
func ByteToFloat32(v []byte) float32 {
|
||||
bits := binary.LittleEndian.Uint32(v)
|
||||
return math.Float32frombits(bits)
|
||||
}
|
||||
|
||||
func Float64ToByte(v float64) []byte {
|
||||
bits := math.Float64bits(v)
|
||||
bts := make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(bts, bits)
|
||||
return bts
|
||||
}
|
||||
|
||||
func ByteToFloat64(v []byte) float64 {
|
||||
bits := binary.LittleEndian.Uint64(v)
|
||||
return math.Float64frombits(bits)
|
||||
}
|
||||
|
||||
func Int64ToBytes(n int64) []byte {
|
||||
bytesBuf := bytes.NewBuffer([]byte{})
|
||||
_ = binary.Write(bytesBuf, binary.BigEndian, n)
|
||||
return bytesBuf.Bytes()
|
||||
}
|
||||
|
||||
func BytesToInt64(bys []byte) (data int64) {
|
||||
byteBuff := bytes.NewBuffer(bys)
|
||||
_ = binary.Read(byteBuff, binary.BigEndian, &data)
|
||||
return
|
||||
}
|
||||
|
||||
func SplitInteger(m, n int) (ints []int) {
|
||||
quotient := m / n
|
||||
remainder := m % n
|
||||
|
||||
Reference in New Issue
Block a user