Skip to content

Commit dd58e45

Browse files
committed
Add regexes: ethminer, T-Rex, lolMiner, PhoenixMiner; Edit ethash test: diff, blob;
1 parent 7e55640 commit dd58e45

1 file changed

Lines changed: 101 additions & 38 deletions

File tree

mm.js

Lines changed: 101 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,39 @@ const AGENT = "Meta Miner " + VERSION;
4242
// the multiplier is for supporting hashrate prints in different units
4343
// the nr benchmark prints is to make sure hashrate has stabilized before snapping the benchmark value
4444
const hashrate_regexes = [
45-
[1, 1, /\[[^\]]+\] speed 2.5s\/60s\/15m [\d\.]+ ([\d\.]+)\s/], // for old xmrig
46-
[1, 1, /\[[^\]]+\] speed 10s\/60s\/15m [\d\.n/a]+ ([\d\.]+)\s/], // for new xmrig
47-
[1, 1, /\s+miner\s+speed 10s\/60s\/15m [\d\.n/a]+ ([\d\.]+)\s/], // for xmrig v6+
48-
[1, 1, /Totals \(ALL\):\s+[\d\.]+\s+([1-9]\d*\.\d+|0\.[1-9]\d*)\s/], // xmr-stak
49-
[1, 1, /Total Speed: ([\d\.]+) H\/s,/], // claymore
50-
[1, 1, /\(Avr ([\d\.]+)H\/s\)/], // CryptoDredge
51-
[1e3, 3, /Total[^:]+:\s*([\d\.]+)\s*kh\/s/], // TeamRedMiner variant 1 (kh/s)
52-
[1, 3, /Total[^:]+:\s*([\d\.]+)\s*h\/s/], // TeamRedMiner variant 2 (h/s)
53-
[1, 1, /Mining at\s+([\d\.]+) gps/], // tube4referenceMiner (use mode=rolling command line option)
54-
[1, 1, /mining at\s+([\d\.]+) gps/], // SwapReferenceMiner (use mode=rolling command line option)
55-
[1, 2, /Total\s+:\s+([\d\.]+) gps/], // MoneroVMiner
56-
[1, 2, /([\d\.]+) G\/s/], // gminer
57-
[1000000, 2, /([\d\.]+) MH\/s/], // gminer
45+
[1, 2, /^\|.*[^\d\.]([\d\.]+) G\/s.*\|$/, 'gminer (gh/s)'],
46+
[1e6, 2, /^\|.*[^\d\.]([\d\.]+) M\/s.*\|$/, 'gminer (mh/s)'],
47+
[1, 3, /^\[[^\]]+\] Total[^:]+:\s*([\d\.]+)\s*[Hh]\/s/, 'TeamRedMiner (h/s)'],
48+
[1e3, 3, /^\[[^\]]+\] Total[^:]+:\s*([\d\.]+)\s*[Kk]h\/s/, 'TeamRedMiner (kh/s)'],
49+
[1e6, 3, /^\[[^\]]+\] Total[^:]+:\s*([\d\.]+)\s*[Mm]h\/s,/, 'TeamRedMiner (mh/s)'],
50+
[1e9, 3, /^\[[^\]]+\] Total[^:]+:\s*([\d\.]+)\s*[Gg]h\/s,/, 'TeamRedMiner (gh/s)'],
51+
[1, 2, /^ethminer .* ([\d\.]+) h - /, 'ethminer (h/s)'],
52+
[1e3, 2, /^ethminer .* ([\d\.]+) Kh - /, 'ethminer (kh/s)'],
53+
[1e6, 2, /^ethminer .* ([\d\.]+) Mh - /, 'ethminer (mh/s)'],
54+
[1e9, 2, /^ethminer .* ([\d\.]+) Gh - /, 'ethminer (gh/s)'],
55+
[1, 2, /^GPU #(\d+): .* - ([\d\.]+) H\/s/, 'T-Rex (h/s)'],
56+
[1e3, 2, /^GPU #(\d+): .* - ([\d\.]+) KH\/s/, 'T-Rex (kh/s)'],
57+
[1e6, 2, /^GPU #(\d+): .* - ([\d\.]+) MH\/s/, 'T-Rex (mh/s)'],
58+
[1e9, 2, /^GPU #(\d+): .* - ([\d\.]+) GH\/s/, 'T-Rex (gh/s)'],
59+
[1, 2, /^Average speed \(30s\): ([\d\.]+) h\/s/, 'lolMiner (h/s)'],
60+
[1e3, 2, /^Average speed \(30s\): ([\d\.]+) kh\/s/, 'lolMiner (kh/s)'],
61+
[1e6, 2, /^Average speed \(30s\): ([\d\.]+) mh\/s/, 'lolMiner (mh/s)'],
62+
[1e9, 2, /^Average speed \(30s\): ([\d\.]+) gh\/s/, 'lolMiner (gh/s)'],
63+
[1, 2, /^Eth speed: ([\d\.]+) H\/s, shares:.*time:/, 'PhoenixMiner (h/s)'],
64+
[1e3, 2, /^Eth speed: ([\d\.]+) KH\/s, shares:.*time:/, 'PhoenixMiner (kh/s)'],
65+
[1e6, 2, /^Eth speed: ([\d\.]+) MH\/s, shares:.*time:/, 'PhoenixMiner (mh/s)'],
66+
[1e9, 2, /^Eth speed: ([\d\.]+) GH\/s, shares:.*time:/, 'PhoenixMiner (gh/s)'],
67+
[1, 1, /\[[^\]]+\] speed 2.5s\/60s\/15m [\d\.]+ ([\d\.]+)\s/, 'xmrig old'],
68+
[1, 1, /\[[^\]]+\] speed 10s\/60s\/15m [\d\.n/a]+ ([\d\.]+)\s/, 'xmrig new'],
69+
[1, 1, /\s+miner\s+speed 10s\/60s\/15m [\d\.n/a]+ ([\d\.]+)\s/, 'xmrig v6+'],
70+
[1, 1, /Totals \(ALL\):\s+[\d\.]+\s+([1-9]\d*\.\d+|0\.[1-9]\d*)\s/, 'xmr-stak'],
71+
[1, 1, /Total Speed: ([\d\.]+) H\/s,/, 'claymore'],
72+
[1, 1, /\(Avr ([\d\.]+)H\/s\)/, 'CryptoDredge'],
73+
[1, 1, /Mining at\s+([\d\.]+) gps/, 'tube4referenceMiner (use mode=rolling command line option)'],
74+
[1, 1, /mining at\s+([\d\.]+) gps/, 'SwapReferenceMiner (use mode=rolling command line option)'],
75+
[1, 2, /Total\s+:\s+([\d\.]+) gps/, 'MoneroVMiner'],
5876
];
77+
const hashrate_per_gpu = []
5978

6079
function algo_hashrate_factor(algo) {
6180
switch (algo) {
@@ -452,10 +471,10 @@ function start_miner_raw(exe, args, out_cb) {
452471
let proc = child_process.spawn(exe, args, is_miner_stdin ? {stdio: ['inherit', 'pipe', 'pipe']} : {});
453472

454473
proc.stdout.on('data', (data) => {
455-
if (out_cb) out_cb(`${data}`);
474+
if (out_cb) out_cb(data.toString());
456475
});
457476
proc.stderr.on('data', (data) => {
458-
if (out_cb) out_cb(`${data}`);
477+
if (out_cb) out_cb(data.toString());
459478
});
460479
proc.on('close', (code) => {
461480
if (is_verbose_mode) {
@@ -841,15 +860,15 @@ function do_miner_perf_runs(cb) {
841860
jsonrpc: "2.0",
842861
method: "mining.set_difficulty",
843862
params: [
844-
1000000
863+
10.24
845864
],
846865
}) + "\n" + JSON.stringify({
847866
jsonrpc: "2.0",
848867
method: "mining.notify",
849868
params: [
850869
"benchmark1", // job_id
851-
"e79f0f63030bf691445c2b9d0266b24a9619e355194067f2ad2c73a8e0a26c65", // seed hash
852-
"feb4243b885cd1af5337979f5d81849335cab197b4993e5c61ea4b43b43dbbc6", // hash
870+
"ffaad0781cfec93fee66657ef8a9f132f422becba3626b5d936ad3cb1f8228d4", // seed hash
871+
"a917c993b27e4a15c6ed3611bcaa7e5eee5c9b984053f6c1270032c0c4d6dc83", // hash
853872
true,
854873
]
855874
}) + "\n");
@@ -900,27 +919,71 @@ function do_miner_perf_runs(cb) {
900919
};
901920
let nr_prints_needed = -1;
902921
let nr_prints_found = 0;
903-
miner_proc = start_miner(cmd, function(str) {
904-
print_messages(str);
905-
str = str.replace(/\x1b\[[0-9;]*m/g, ""); // remove all colors
906-
for (let i in hashrate_regexes) {
907-
const hashrate_regex = hashrate_regexes[i];
908-
const m = str.match(hashrate_regex[2]);
909-
if (m) {
910-
if (nr_prints_needed < 0) nr_prints_needed = hashrate_regex[1];
911-
const hashrate = parseFloat(m[1]) * hashrate_regex[0] * algo_hashrate_factor(algo);
912-
if (++nr_prints_found >= nr_prints_needed) {
913-
const algo_deps = bench_algo_deps(algo, hashrate);
914-
for (let algo_dep in algo_deps) {
915-
log("Setting performance for " + algo_dep + " algo to " + algo_deps[algo_dep]);
916-
c.algo_perf[algo_dep] = algo_deps[algo_dep];
922+
let chunk_leftover = '';
923+
miner_proc = start_miner(cmd, function(chunk) {
924+
chunk = [chunk_leftover, chunk].join('');
925+
const buf_size = chunk.lastIndexOf('\n');
926+
chunk_leftover = chunk.slice(chunk, buf_size);
927+
const eol = `\x1b[0m\n`;
928+
let gpu_max = -1;
929+
let gpu_max_valid = false;
930+
const variance = [];
931+
const hashrate_raw = [];
932+
const hashrate_prev = [];
933+
let line = 0;
934+
processing:
935+
for (let str of chunk.split('\n')) {
936+
print_messages(str + eol);
937+
str = str.replace(/\x1b\[[0-9;]*m/g, ""); // remove all colors
938+
for (let i in hashrate_regexes) {
939+
const hashrate_regex = hashrate_regexes[i];
940+
const m = str.match(hashrate_regex[2]);
941+
if (m) {
942+
if (nr_prints_needed < 0) nr_prints_needed = hashrate_regex[1];
943+
let gpu = (m.length === 3) ? m[1] : 0;
944+
if (gpu_max > -1 && gpu <= gpu_max) gpu_max_valid = true;
945+
if (gpu > gpu_max) gpu_max = gpu;
946+
if (m.length === 3) {
947+
m[1] = m[2];
948+
m.length = 2;
949+
}
950+
hashrate_raw[gpu] = parseFloat(m[1]);
951+
if (!gpu_max_valid) {
952+
hashrate_prev[gpu] = hashrate_raw[gpu];
953+
} else if (hashrate_raw[gpu] > 0) {
954+
if (hashrate_prev.length < gpu) hashrate_prev[gpu] = hashrate_raw[gpu];
955+
variance[gpu] = hashrate_prev[gpu] / hashrate_raw[gpu];
956+
let variance_good = true;
957+
for (const j in variance) {
958+
if (!(variance[j] > 0.98 && variance[j] < 1.02)) {
959+
variance_good = false;
960+
}
961+
}
962+
if (gpu === gpu_max) {
963+
let hashrate = 0;
964+
for (const j in hashrate_raw) {
965+
hashrate += hashrate_raw[j] * hashrate_regex[0] * algo_hashrate_factor(algo);
966+
}
967+
if (variance_good && ++nr_prints_found >= nr_prints_needed) {
968+
const algo_deps = bench_algo_deps(algo, hashrate);
969+
for (let algo_dep in algo_deps) {
970+
log("Setting performance for " + algo_dep + " algo to " + algo_deps[algo_dep]);
971+
c.algo_perf[algo_dep] = algo_deps[algo_dep];
972+
}
973+
miner_proc.on('close', (code) => { clearTimeout(timeout); resolve(); });
974+
tree_kill(miner_proc.pid);
975+
break processing;
976+
} else {
977+
let msg = "Read";
978+
if (!variance_good) {
979+
msg = "Skip";
980+
}
981+
log(msg + " performance for " + algo + " algo of " + hashrate + ", waiting for " +
982+
(nr_prints_needed - nr_prints_found) + " more print(s).");
983+
}
984+
}
985+
hashrate_prev[gpu] = hashrate_raw[gpu];
917986
}
918-
miner_proc.on('close', (code) => { clearTimeout(timeout); resolve(); });
919-
tree_kill(miner_proc.pid);
920-
break;
921-
} else {
922-
log("Read performance for " + algo + " algo to " + hashrate + ", waiting for " +
923-
(nr_prints_needed - nr_prints_found) + " more print(s).");
924987
}
925988
}
926989
}

0 commit comments

Comments
 (0)