Skip to content

Commit

Permalink
Add a k6 script to demo profile collection with Pyroscope
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewslotin committed Jul 17, 2024
1 parent 9222c45 commit e4c84c0
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions k6/foundations/15.basic.profiling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import http from "k6/http";
import { check, sleep } from "k6";
import pyroscope from "https://jslib.k6.io/http-instrumentation-pyroscope/1.0.0/index.js";

const BASE_URL = __ENV.BASE_URL || "http://localhost:3333";

export const options = {
vus: 15,
duration: "1m",
};

pyroscope.instrumentHTTP();

export default function () {
let restrictions = {
maxCaloriesPerSlice: 500,
mustBeVegetarian: false,
excludedIngredients: ["pepperoni"],
excludedTools: ["knife"],
maxNumberOfToppings: 6,
minNumberOfToppings: 2,
};
let res = http.post(`${BASE_URL}/api/pizza`, JSON.stringify(restrictions), {
headers: {
"Content-Type": "application/json",
"X-User-ID": 23423,
},
});
check(res, { "status is 200": (res) => res.status === 200 });
console.log(
`${res.json().pizza.name} (${res.json().pizza.ingredients.length} ingredients)`,
);
sleep(1);
}

0 comments on commit e4c84c0

Please sign in to comment.