pikvm/pikvm#1041: Randomized recorder events

This commit is contained in:
Maxim Devaev
2023-07-07 14:03:44 +03:00
parent 26d807a4b9
commit 64728dc0e6
2 changed files with 59 additions and 6 deletions

View File

@@ -70,6 +70,12 @@ export var tools = new function() {
return btoa(text).replace("=", "_");
};
self.getRandomInt = function(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
};
self.formatSize = function(size) {
if (size > 0) {
let index = Math.floor( Math.log(size) / Math.log(1024) );