improve ufuzz duty cycle heuristic

This commit is contained in:
alexlamsl 2020-08-19 21:40:56 +08:00
parent e8db526f51
commit 647d2c9b98

View File

@ -22,15 +22,14 @@ function read(url, callback) {
}); });
} }
var queued = 0, total = 0; var queued = 0, total = 0, earliest, now = Date.now();
var earliest, latest;
process.on("beforeExit", function() { process.on("beforeExit", function() {
if (queued > 3) { if (queued > 3) {
process.stdout.write("0"); process.stdout.write("0");
} else if (total < 2) { } else if (now - earliest > 0 && total > 1) {
process.stdout.write("3600000"); process.stdout.write(Math.min(20 * (now - earliest) / (total - 1), 6300000).toFixed(0));
} else { } else {
process.stdout.write(Math.min(20 * (latest - earliest) / (total - 1), 5400000).toFixed(0)); process.stdout.write("3600000");
} }
}); });
read(base + "/actions/workflows/ufuzz.yml/runs?event=schedule", function(reply) { read(base + "/actions/workflows/ufuzz.yml/runs?event=schedule", function(reply) {
@ -41,9 +40,9 @@ read(base + "/actions/workflows/ufuzz.yml/runs?event=schedule", function(reply)
reply.jobs.forEach(function(job) { reply.jobs.forEach(function(job) {
if (job.status == "queued") queued++; if (job.status == "queued") queued++;
total++; total++;
if (!job.started_at) return;
var start = new Date(job.started_at); var start = new Date(job.started_at);
if (!(earliest < start)) earliest = start; if (!(earliest < start)) earliest = start;
if (!(latest > start)) latest = start;
}); });
}); });
}); });