Add BenchmarkProcessor002ParseOnly, to get at least a hint of the JSON speed.
This commit is contained in:
parent
849d859db4
commit
b2128904e2
File diff suppressed because it is too large
Load Diff
|
@ -14,7 +14,9 @@
|
||||||
package extraction
|
package extraction
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -200,3 +202,25 @@ func BenchmarkProcessor002Process(b *testing.B) {
|
||||||
|
|
||||||
b.Logf("Allocated %d at %f per cycle with %d cycles.", allocated, float64(allocated)/float64(b.N), b.N)
|
b.Logf("Allocated %d at %f per cycle with %d cycles.", allocated, float64(allocated)/float64(b.N), b.N)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkProcessor002ParseOnly(b *testing.B) {
|
||||||
|
b.StopTimer()
|
||||||
|
data, err := ioutil.ReadFile("fixtures/test0_0_1-0_0_2-large.json")
|
||||||
|
if err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
ing := fakeIngester{}
|
||||||
|
b.StartTimer()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
if err := Processor002.ProcessSingle(bytes.NewReader(data), ing, &ProcessOptions{}); err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type fakeIngester struct{}
|
||||||
|
|
||||||
|
func (i fakeIngester) Ingest(model.Samples) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
dto "github.com/prometheus/client_model/go"
|
dto "github.com/prometheus/client_model/go"
|
||||||
|
|
||||||
"github.com/matttproud/golang_protobuf_extensions/ext"
|
"github.com/matttproud/golang_protobuf_extensions/ext"
|
||||||
|
@ -40,6 +39,10 @@ import (
|
||||||
// the difference becomes less relevant, only ~4x.
|
// the difference becomes less relevant, only ~4x.
|
||||||
//
|
//
|
||||||
// The test data contains 248 samples.
|
// The test data contains 248 samples.
|
||||||
|
//
|
||||||
|
// BenchmarkProcessor002ParseOnly in the extraction package is not quite
|
||||||
|
// comparable to the benchmarks here, but it gives an idea: JSON parsing is even
|
||||||
|
// slower than text parsing and needs a comparable amount of allocs.
|
||||||
|
|
||||||
// BenchmarkParseText benchmarks the parsing of a text-format scrape into metric
|
// BenchmarkParseText benchmarks the parsing of a text-format scrape into metric
|
||||||
// family DTOs.
|
// family DTOs.
|
||||||
|
|
Loading…
Reference in New Issue