Add BenchmarkProcessor002ParseOnly, to get at least a hint of the JSON speed.

This commit is contained in:
Bjoern Rabenstein 2015-01-27 17:16:23 +01:00
parent 849d859db4
commit b2128904e2
3 changed files with 1060 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,9 @@
package extraction
import (
"bytes"
"errors"
"io/ioutil"
"os"
"path"
"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)
}
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
}

View File

@ -19,7 +19,6 @@ import (
"io"
"io/ioutil"
"testing"
dto "github.com/prometheus/client_model/go"
"github.com/matttproud/golang_protobuf_extensions/ext"
@ -40,6 +39,10 @@ import (
// the difference becomes less relevant, only ~4x.
//
// 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
// family DTOs.