Skip to content

Commit

Permalink
chore: add variables benchmark (#304)
Browse files Browse the repository at this point in the history
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

Noticed we're not reusing connections in variable queries. Making a
benchmark for it before making the fix.

### How

Add a benchmark that does a query with 5 variables, meaning 5 queries.
  • Loading branch information
danieljharvey authored Sep 21, 2023
1 parent 3b50c69 commit 89d6c80
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions benchmarks/component/benchmarks/select-variables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { check } from "k6";
import http from "k6/http";
import { newSummaryHandler } from "../common.js";

const testid = "select_variables";
const agentSocket = __ENV.AGENT_SOCKET || "localhost:8100";
const url = `http://${agentSocket}/query`;
const data = {
collection: "Album",
query: {
fields: {
Title: {
type: "column",
column: "Title",
arguments: {},
},
},
where: {
type: "binary_comparison_operator",
column: {
type: "column",
name: "Title",
path: [],
},
operator: {
type: "other",
name: "_like",
},
value: {
type: "variable",
name: "search",
},
},
},
arguments: {},
collection_relationships: {},
variables: [
{
search: "%Garage%",
},
{
search: "%Good%",
},
{
search: "%Rock%",
},
{
search: "%Dog%",
},
{
search: "%Log%",
},
],
};

export default function () {
const response = http.post(url, JSON.stringify(data), {
headers: {
"Content-Type": "application/json",
},
});

check(response, {
"status is 200": (r) => r.status == 200,
});
}

export const handleSummary = newSummaryHandler(testid);

export const options = {
tags: {
testid,
},
scenarios: {
short_sustained: {
executor: "constant-vus",
vus: 100,
duration: "10s",
},
},
thresholds: {
checks: [
{
threshold: "rate == 1",
abortOnFail: true,
},
],
},
};

0 comments on commit 89d6c80

Please sign in to comment.