🎉 First commit
This commit is contained in:
24
load-test.js
Normal file
24
load-test.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import http from "k6/http";
|
||||
import { sleep } from 'k6';
|
||||
|
||||
export default function () {
|
||||
for (let i = 0; i < 250; i++) {
|
||||
var rand = Math.random()
|
||||
if (rand > 0.5) {
|
||||
http.get(`http://127.0.0.1:8080/get/${random_string(1)}`);
|
||||
} else {
|
||||
http.post(`http://127.0.0.1:8080/set/${random_string(1)}`, random_string(5));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function random_string(length) {
|
||||
var result = '';
|
||||
var characters = 'abcdefghijklmnopqrstuvwxyz';
|
||||
var charactersLength = characters.length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user