mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-20 23:46:23 +01:00
26 lines
981 B
Go
26 lines
981 B
Go
|
package vmimport
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func BenchmarkRowsUnmarshal(b *testing.B) {
|
||
|
s := `{"metric":{"__name__":"up","job":"node_exporter","instance":"localhost:9100"},"values":[0,0,0],"timestamps":[1549891472010,1549891487724,1549891503438]}
|
||
|
{"metric":{"__name__":"up","job":"prometheus","instance":"localhost:9090"},"values":[1,1,1],"timestamps":[1549891461511,1549891476511,1549891491511]}
|
||
|
{"metric":{"__name__":"up","job":"node_exporter","instance":"foobar.com:9100"},"values":[0,0,0],"timestamps":[1549891472010,1549891487724,1549891503438]}
|
||
|
{"metric":{"__name__":"up","job":"prometheus","instance":"xxx.yyy.zzz:9090"},"values":[1,1,1],"timestamps":[1549891461511,1549891476511,1549891491511]}
|
||
|
`
|
||
|
b.SetBytes(int64(len(s)))
|
||
|
b.ReportAllocs()
|
||
|
b.RunParallel(func(pb *testing.PB) {
|
||
|
var rows Rows
|
||
|
for pb.Next() {
|
||
|
rows.Unmarshal(s)
|
||
|
if len(rows.Rows) != 4 {
|
||
|
panic(fmt.Errorf("unexpected number of rows parsed; got %d; want 4", len(rows.Rows)))
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|