@@ -38,12 +38,17 @@ const VERSION = "v2.1";
38
38
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
39
39
const AGENT = "Meta Miner " + VERSION ;
40
40
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
41
44
const hashrate_regexes = [
42
- / \[ [ ^ \] ] + \] s p e e d 2 .5 s \/ 6 0 s \/ 1 5 m [ \d \. ] + ( [ \d \. ] + ) \s / , // for old xmrig
43
- / \[ [ ^ \] ] + \] s p e e d 1 0 s \/ 6 0 s \/ 1 5 m [ \d \. ] + ( [ \d \. ] + ) \s / , // for new xmrig
44
- / T o t a l s \( A L L \) : \s + [ \d \. ] + \s + ( [ 1 - 9 ] \d * \. \d + | 0 \. [ 1 - 9 ] \d * ) \s / , // xmr-stak
45
- / T o t a l S p e e d : ( [ \d \. ] + ) H \/ s , / , // claymore
46
- / \( A v r ( [ \d \. ] + ) H \/ s \) / , // CryptoDredge
45
+ [ 1 , 1 , / \[ [ ^ \] ] + \] s p e e d 2 .5 s \/ 6 0 s \/ 1 5 m [ \d \. ] + ( [ \d \. ] + ) \s / ] , // for old xmrig
46
+ [ 1 , 1 , / \[ [ ^ \] ] + \] s p e e d 1 0 s \/ 6 0 s \/ 1 5 m [ \d \. ] + ( [ \d \. ] + ) \s / ] , // for new xmrig
47
+ [ 1 , 1 , / T o t a l s \( A L L \) : \s + [ \d \. ] + \s + ( [ 1 - 9 ] \d * \. \d + | 0 \. [ 1 - 9 ] \d * ) \s / ] , // xmr-stak
48
+ [ 1 , 1 , / T o t a l S p e e d : ( [ \d \. ] + ) H \/ s , / ] , // claymore
49
+ [ 1 , 1 , / \( A v r ( [ \d \. ] + ) H \/ s \) / ] , // CryptoDredge
50
+ [ 1e3 , 3 , / T o t a l [ ^ : ] + : \s * ( [ \d \. ] + ) \s * k h \/ s / ] , // TeamRedMiner variant 1 (kh/s)
51
+ [ 1 , 3 , / T o t a l [ ^ : ] + : \s * ( [ \d \. ] + ) \s * h \/ s / ] , // TeamRedMiner variant 2 (h/s)
47
52
] ;
48
53
49
54
// main algos we bench for
@@ -283,8 +288,8 @@ function print_all_messages(str) {
283
288
const str2 = str . replace ( / \x1b \[ [ 0 - 9 ; ] * m / g, "" ) ; // remove all colors
284
289
for ( let i in hashrate_regexes ) {
285
290
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 ] ;
288
293
}
289
294
}
290
295
}
@@ -653,23 +658,30 @@ function do_miner_perf_runs(cb) {
653
658
'","algo":"' + algo + '","height":0,"seed_hash":"0000000000000000000000000000000000000000000000000000000000000001","job_id":"benchmark1","target":"01000000","id":"benchmark"},"status":"OK"}}\n'
654
659
) ;
655
660
} ;
661
+ let nr_prints_needed = - 1 ;
662
+ let nr_prints_found = 0 ;
656
663
miner_proc = start_miner ( cmd , function ( str ) {
657
664
print_messages ( str ) ;
658
665
str = str . replace ( / \x1b \[ [ 0 - 9 ; ] * m / g, "" ) ; // remove all colors
659
666
for ( let i in hashrate_regexes ) {
660
667
const hashrate_regex = hashrate_regexes [ i ] ;
661
- const m = str . match ( hashrate_regex ) ;
668
+ const m = str . match ( hashrate_regex [ 2 ] ) ;
662
669
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)." ) ;
668
684
}
669
- c . algo_perf [ algo ] = hashrate ;
670
- miner_proc . on ( 'close' , ( code ) => { clearTimeout ( timeout ) ; resolve ( ) ; } ) ;
671
- tree_kill ( miner_proc . pid ) ;
672
- break ;
673
685
}
674
686
}
675
687
} ) ;
0 commit comments