Skip to content

Commit bb0899c

Browse files
committed
Added rx/loki support and redesigned algo bench support
2 parents bf6b7c0 + bc17d44 commit bb0899c

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

mm.js

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,17 @@ const VERSION = "v2.1";
3838
const DEFAULT_ALGO = "cn/r"; // this is algo that is assumed to be sent by pool if its job does not contain algo stratum extension
3939
const AGENT = "Meta Miner " + VERSION;
4040

41+
// [multiplier, nr benchmark prints, regex]
42+
// the multiplier is for supporting hashrate prints in different units
43+
// the nr benchmark prints is to make sure hashrate has stabilized before snapping the benchmark value
4144
const hashrate_regexes = [
42-
/\[[^\]]+\] speed 2.5s\/60s\/15m [\d\.]+ ([\d\.]+)\s/, // for old xmrig
43-
/\[[^\]]+\] speed 10s\/60s\/15m [\d\.]+ ([\d\.]+)\s/, // for new xmrig
44-
/Totals \(ALL\):\s+[\d\.]+\s+([1-9]\d*\.\d+|0\.[1-9]\d*)\s/, // xmr-stak
45-
/Total Speed: ([\d\.]+) H\/s,/, // claymore
46-
/\(Avr ([\d\.]+)H\/s\)/, // CryptoDredge
45+
[1, 1, /\[[^\]]+\] speed 2.5s\/60s\/15m [\d\.]+ ([\d\.]+)\s/], // for old xmrig
46+
[1, 1, /\[[^\]]+\] speed 10s\/60s\/15m [\d\.]+ ([\d\.]+)\s/], // for new xmrig
47+
[1, 1, /Totals \(ALL\):\s+[\d\.]+\s+([1-9]\d*\.\d+|0\.[1-9]\d*)\s/], // xmr-stak
48+
[1, 1, /Total Speed: ([\d\.]+) H\/s,/], // claymore
49+
[1, 1, /\(Avr ([\d\.]+)H\/s\)/], // CryptoDredge
50+
[1e3, 3, /Total[^:]+:\s*([\d\.]+)\s*kh\/s/], // TeamRedMiner variant 1 (kh/s)
51+
[1, 3, /Total[^:]+:\s*([\d\.]+)\s*h\/s/], // TeamRedMiner variant 2 (h/s)
4752
];
4853

4954
// main algos we bench for
@@ -283,8 +288,8 @@ function print_all_messages(str) {
283288
const str2 = str.replace(/\x1b\[[0-9;]*m/g, ""); // remove all colors
284289
for (let i in hashrate_regexes) {
285290
const hashrate_regex = hashrate_regexes[i];
286-
const m = str2.match(hashrate_regex);
287-
if (m) last_miner_hashrate = parseFloat(m[1]);
291+
const m = str2.match(hashrate_regex[2]);
292+
if (m) last_miner_hashrate = parseFloat(m[1]) * hashrate_regex[0];
288293
}
289294
}
290295
}
@@ -653,23 +658,30 @@ function do_miner_perf_runs(cb) {
653658
'","algo":"' + algo + '","height":0,"seed_hash":"0000000000000000000000000000000000000000000000000000000000000001","job_id":"benchmark1","target":"01000000","id":"benchmark"},"status":"OK"}}\n'
654659
);
655660
};
661+
let nr_prints_needed = -1;
662+
let nr_prints_found = 0;
656663
miner_proc = start_miner(cmd, function(str) {
657664
print_messages(str);
658665
str = str.replace(/\x1b\[[0-9;]*m/g, ""); // remove all colors
659666
for (let i in hashrate_regexes) {
660667
const hashrate_regex = hashrate_regexes[i];
661-
const m = str.match(hashrate_regex);
668+
const m = str.match(hashrate_regex[2]);
662669
if (m) {
663-
const hashrate = parseFloat(m[1]);
664-
const algo_deps = bench_algo_deps(algo, hashrate);
665-
for (let algo_dep in algo_deps) {
666-
log("Setting performance for " + algo_dep + " algo to " + algo_deps[algo_dep]);
667-
c.algo_perf[algo_dep] = algo_deps[algo_dep];
670+
if (nr_prints_needed < 0) nr_prints_needed = hashrate_regex[1];
671+
const hashrate = parseFloat(m[1]) * hashrate_regex[0];
672+
if (++nr_prints_found >= nr_prints_needed) {
673+
const algo_deps = bench_algo_deps(algo, hashrate);
674+
for (let algo_dep in algo_deps) {
675+
log("Setting performance for " + algo_dep + " algo to " + algo_deps[algo_dep]);
676+
c.algo_perf[algo_dep] = algo_deps[algo_dep];
677+
}
678+
miner_proc.on('close', (code) => { clearTimeout(timeout); resolve(); });
679+
tree_kill(miner_proc.pid);
680+
break;
681+
} else {
682+
log("Read performance for " + algo + " algo to " + hashrate + ", waiting for " +
683+
(nr_prints_needed - nr_prints_found) + " more print(s).");
668684
}
669-
c.algo_perf[algo] = hashrate;
670-
miner_proc.on('close', (code) => { clearTimeout(timeout); resolve(); });
671-
tree_kill(miner_proc.pid);
672-
break;
673685
}
674686
}
675687
});

0 commit comments

Comments
 (0)