Skip to content

Instantly share code, notes, and snippets.

@mstoykov
Created December 15, 2020 12:25
Show Gist options
  • Save mstoykov/ea62b0d16dc21261779f46db0fe8bd53 to your computer and use it in GitHub Desktop.
Save mstoykov/ea62b0d16dc21261779f46db0fe8bd53 to your computer and use it in GitHub Desktop.
var http = require("k6/http");
var s = [{"user": "myuser", "password": "password12345"},
{"user": "myuser", "password": "password12345"},
{"user": "myuser", "password": "password12345"},
{"user": "myuser", "password": "password12345"},
{"user": "myuser", "password": "password12345"},
{"user": "myuser", "password": "password12345"},
{"user": "myuser", "password": "password12345"},
{"user": "myuser", "password": "password12345"},
{"user": "myuser", "password": "password12345"},
{"user": "myuser", "password": "password12345"}];
exports.default = function () {
http.post("https://httpbin.test.k6.io/anything", JSON.stringify(s[Math.floor(Math.random()*s.length)]))
}
var http = require("k6/http");
var SharedArray = require("k6/data").SharedArray;
function generateArray() {
return JSON.parse(open("./arr.json"));
}
var s = new SharedArray("something", generateArray);
exports.default = function () {
http.post("https://httpbin.test.k6.io/anything", JSON.stringify(s[Math.floor(Math.random()*s.length)]))
}
@mstoykov
Copy link
Author

The arr.json is 100k lines such as the one in noshare array. The reason why the one array is much smaller is that otherwise, it will use too much memory :D
Both were run with --compatibility-mode=base -u 1000 -d 30s --no-teardown --no-setup
The results averaged over 3 runs are :
no-share: 146%CPU (Really stable somehow) 1055-1064M (again really stable) 1937-1947/s iterations
share: 163-168% CPU and 1162-1222M memory usage 1899-1946/s iterations

I ran it once for 5minutes ... because I have to do other stuff:
no-share:143% CPU, 1346M 1982.689996/s iterations
share: 166% CPU, 1455M 1985.615058/s iterations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment