Skip to content
Snippets Groups Projects
Commit fefab2e2 authored by thijsheijden's avatar thijsheijden
Browse files

Added some benchmarks for query conversion

parent 88d014fb
No related branches found
No related tags found
No related merge requests found
package convertquery
import "testing"
func BenchmarkConvertEmptyQuery(b *testing.B) {
// Setup for test
// Create query conversion service
service := NewService()
query := []byte(`{
"return": {
"entities": [],
"relations": []
},
"entities": [],
"relations": [],
"limit": 5000
}`)
b.ResetTimer()
for i := 0; i < b.N; i++ {
service.ConvertQuery(&query)
}
}
func BenchmarkConvertOneAttributeQuery(b *testing.B) {
// Setup for test
// Create query conversion service
service := NewService()
query := []byte(`{
"return": {
"entities": [
0
],
"relations": []
},
"entities": [
{
"type": "airports",
"constraints": [
{
"attribute": "state",
"value": "HI",
"dataType": "text",
"matchType": "exact"
}
]
}
],
"relations": [],
"limit": 5000
}`)
b.ResetTimer()
for i := 0; i < b.N; i++ {
service.ConvertQuery(&query)
}
}
func BenchmarkConvertTwoRelationQuery(b *testing.B) {
// Setup for test
// Create query conversion service
service := NewService()
query := []byte(`{
"return": {
"entities": [
0,
1,
2
],
"relations": [
0,
1
]
},
"entities": [
{
"type": "airports",
"constraints": [
{
"attribute": "city",
"value": "New York",
"dataType": "text",
"matchType": "exact"
}
]
},
{
"type": "airports",
"constraints": [
{
"attribute": "city",
"value": "San Francisco",
"dataType": "text",
"matchType": "exact"
}
]
},
{
"type": "airports",
"constraints": [
{
"attribute": "state",
"value": "HI",
"dataType": "text",
"matchType": "exact"
}
]
}
],
"relations": [
{
"type": "flights",
"depth": {
"min": 1,
"max": 3
},
"entityFrom": 2,
"entityTo": 1,
"constraints": [
{
"attribute": "Day",
"value": "15",
"dataType": "number",
"matchType": "EQ"
}
]
},
{
"type": "flights",
"depth": {
"min": 1,
"max": 1
},
"entityFrom": 0,
"entityTo": -1,
"constraints": []
}
],
"limit": 5000
}`)
b.ResetTimer()
for i := 0; i < b.N; i++ {
service.ConvertQuery(&query)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment