From 2b140d8f1df026e17fbfe4235d5478e148f1d9a5 Mon Sep 17 00:00:00 2001 From: Attila Tajti Date: Tue, 27 Sep 2016 17:15:53 +0200 Subject: [PATCH] search: add BenchmarkQueryPermanodeLocation Change-Id: I27aa4f07685eb12b8f359e08c152ba27b70021a3 --- pkg/search/query_test.go | 69 +++++++++++++++++++++++++++++++ pkg/search/testdata/dude-gps.jpg | Bin 0 -> 2300 bytes 2 files changed, 69 insertions(+) create mode 100644 pkg/search/testdata/dude-gps.jpg diff --git a/pkg/search/query_test.go b/pkg/search/query_test.go index 693f75bb6..0ea5df565 100644 --- a/pkg/search/query_test.go +++ b/pkg/search/query_test.go @@ -4,6 +4,8 @@ import ( "encoding/json" "flag" "fmt" + "io/ioutil" + "path/filepath" "reflect" "sort" "strings" @@ -14,6 +16,7 @@ import ( "camlistore.org/pkg/blob" "camlistore.org/pkg/index" "camlistore.org/pkg/index/indextest" + "camlistore.org/pkg/osutil" . "camlistore.org/pkg/search" "camlistore.org/pkg/test" "go4.org/types" @@ -1510,3 +1513,69 @@ func benchmarkQueryPermanodes(b *testing.B, describe bool) { } }) } + +func BenchmarkQueryPermanodeLocation(b *testing.B) { + b.ReportAllocs() + testQueryTypes(b, corpusTypeOnly, func(qt *queryTest) { + id := qt.id + + // Upload a basic image + camliRootPath, err := osutil.GoPackagePath("camlistore.org") + if err != nil { + panic("Package camlistore.org no found in $GOPATH or $GOPATH not defined") + } + uploadFile := func(file string, modTime time.Time) blob.Ref { + fileName := filepath.Join(camliRootPath, "pkg", "search", "testdata", file) + contents, err := ioutil.ReadFile(fileName) + if err != nil { + panic(err) + } + br, _ := id.UploadFile(file, string(contents), modTime) + return br + } + fileRef := uploadFile("dude-gps.jpg", time.Time{}) + + var n int + newPn := func() blob.Ref { + n++ + return id.NewPlannedPermanode(fmt.Sprint(n)) + } + + pn := id.NewPlannedPermanode("photo") + id.SetAttribute(pn, "camliContent", fileRef.String()) + + for i := 0; i < 5; i++ { + pn := newPn() + id.SetAttribute(pn, "camliNodeType", "foursquare.com:venue") + id.SetAttribute(pn, "latitude", fmt.Sprint(50-i)) + id.SetAttribute(pn, "longitude", fmt.Sprint(i)) + for j := 0; j < 5; j++ { + qn := newPn() + id.SetAttribute(qn, "camliNodeType", "foursquare.com:checkin") + id.SetAttribute(qn, "foursquareVenuePermanode", pn.String()) + } + } + for i := 0; i < 10; i++ { + pn := newPn() + id.SetAttribute(pn, "foo", fmt.Sprint(i)) + } + + req := &SearchQuery{ + Constraint: &Constraint{ + Permanode: &PermanodeConstraint{ + Location: &LocationConstraint{Any: true}, + }, + }, + } + + h := qt.Handler() + b.ResetTimer() + + for i := 0; i < b.N; i++ { + _, err := h.Query(req) + if err != nil { + qt.t.Fatal(err) + } + } + }) +} diff --git a/pkg/search/testdata/dude-gps.jpg b/pkg/search/testdata/dude-gps.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6c02f8ffdbd8ebcf12ef6860fb7cc90e84bcbb6f GIT binary patch literal 2300 zcmb7Cdpy(YAAfeUDaM#fnCs+H*p|f+<<8tfCC7%uIys9IX-T;xxf}=4s3@75Yf>&P zlFniLRO;s?6-&Zak#dqFitP8DI?nm`_jx^^=kxi#KbPn8ex9#nP%;LKc8QPN2Y|OX zFa-c$00yQ3P>=_MG#aM4>a$_S0I`C@p&$i7JHSJl1Xuo!Llqg30J)L_Kt-nEs{hw% z#A<#46qkxSq|!51EQLhgWJ99ZkgatghfK1eT7!RKB(e>eY(pUdAafc3G*pEoQOKlx z*f$>rM}V@waWaWi2KzRVL;^q=e02&?hWN*adVp1KNT`8y8Yw5Zk2C^bi9slAGt_GZ zcah@AReU84LZr7Q<)QiALT2S#>AN-iZi!MW83l?St~6HwgTWx?5O>KkP zbdN;F?bmgqdHYJ911Eq&AdyG}3ffR8lnh!9gN8(5?OItmoPv@PP63BgR@G8d#%rkH zaO!&M8U%ulj*haLK2cwrsHLr=Eo}mWO3^ZCECz$s#^dnX|F=kf2RICf02BmFAHZ=i z1P&$<00P7iAzf19-v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