mirror of
https://github.com/xmrig/xmrig.git
synced 2025-03-24 08:08:58 +00:00
Added --max-cpu-usage and --safe stub.
This commit is contained in:
parent
0dcf127c26
commit
15b4244ea8
2 changed files with 57 additions and 36 deletions
91
options.c
91
options.c
|
@ -36,21 +36,23 @@
|
||||||
#include "algo/cryptonight/cryptonight.h"
|
#include "algo/cryptonight/cryptonight.h"
|
||||||
|
|
||||||
|
|
||||||
int64_t opt_affinity = -1L;
|
int64_t opt_affinity = -1L;
|
||||||
int opt_n_threads = 0;
|
int opt_n_threads = 0;
|
||||||
int opt_algo_variant = 0;
|
int opt_algo_variant = 0;
|
||||||
int opt_retries = 5;
|
int opt_retries = 5;
|
||||||
int opt_retry_pause = 5;
|
int opt_retry_pause = 5;
|
||||||
int opt_donate_level = DONATE_LEVEL;
|
int opt_donate_level = DONATE_LEVEL;
|
||||||
bool opt_colors = true;
|
int opt_max_cpu_usage = 75;
|
||||||
bool opt_keepalive = false;
|
bool opt_colors = true;
|
||||||
bool opt_background = false;
|
bool opt_keepalive = false;
|
||||||
bool opt_double_hash = false;
|
bool opt_background = false;
|
||||||
char *opt_url = NULL;
|
bool opt_double_hash = false;
|
||||||
char *opt_backup_url = NULL;
|
bool opt_safe = false;
|
||||||
char *opt_userpass = NULL;
|
char *opt_url = NULL;
|
||||||
char *opt_user = NULL;
|
char *opt_backup_url = NULL;
|
||||||
char *opt_pass = NULL;
|
char *opt_userpass = NULL;
|
||||||
|
char *opt_user = NULL;
|
||||||
|
char *opt_pass = NULL;
|
||||||
|
|
||||||
|
|
||||||
static char const usage[] = "\
|
static char const usage[] = "\
|
||||||
|
@ -71,6 +73,8 @@ Options:\n\
|
||||||
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
|
--donate-level=N donate level, default 5%% (5 minutes in 100 minutes)\n\
|
||||||
-B, --background run the miner in the background\n\
|
-B, --background run the miner in the background\n\
|
||||||
-c, --config=FILE load a JSON-format configuration file\n\
|
-c, --config=FILE load a JSON-format configuration file\n\
|
||||||
|
--max-cpu-usage=N maximum cpu usage for automatic threads mode (default 75)\n\
|
||||||
|
--safe safe adjust threads and av settings for current cpu\n\
|
||||||
-h, --help display this help and exit\n\
|
-h, --help display this help and exit\n\
|
||||||
-V, --version output version information and exit\n\
|
-V, --version output version information and exit\n\
|
||||||
";
|
";
|
||||||
|
@ -80,24 +84,26 @@ static char const short_options[] = "a:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vb:";
|
||||||
|
|
||||||
|
|
||||||
static struct option const options[] = {
|
static struct option const options[] = {
|
||||||
{ "algo", 1, NULL, 'a' },
|
{ "algo", 1, NULL, 'a' },
|
||||||
{ "av", 1, NULL, 'v' },
|
{ "av", 1, NULL, 'v' },
|
||||||
{ "background", 0, NULL, 'B' },
|
{ "background", 0, NULL, 'B' },
|
||||||
{ "backup-url", 1, NULL, 'b' },
|
{ "backup-url", 1, NULL, 'b' },
|
||||||
{ "config", 1, NULL, 'c' },
|
{ "config", 1, NULL, 'c' },
|
||||||
{ "cpu-affinity", 1, NULL, 1020 },
|
{ "cpu-affinity", 1, NULL, 1020 },
|
||||||
{ "donate-level", 1, NULL, 1003 },
|
{ "donate-level", 1, NULL, 1003 },
|
||||||
{ "help", 0, NULL, 'h' },
|
{ "help", 0, NULL, 'h' },
|
||||||
{ "keepalive", 0, NULL ,'k' },
|
{ "keepalive", 0, NULL ,'k' },
|
||||||
{ "no-color", 0, NULL, 1002 },
|
{ "max-cpu-usage", 1, NULL, 1004 },
|
||||||
{ "pass", 1, NULL, 'p' },
|
{ "no-color", 0, NULL, 1002 },
|
||||||
{ "retries", 1, NULL, 'r' },
|
{ "pass", 1, NULL, 'p' },
|
||||||
{ "retry-pause", 1, NULL, 'R' },
|
{ "retries", 1, NULL, 'r' },
|
||||||
{ "threads", 1, NULL, 't' },
|
{ "retry-pause", 1, NULL, 'R' },
|
||||||
{ "url", 1, NULL, 'o' },
|
{ "safe", 0, NULL, 1005 },
|
||||||
{ "user", 1, NULL, 'u' },
|
{ "threads", 1, NULL, 't' },
|
||||||
{ "userpass", 1, NULL, 'O' },
|
{ "url", 1, NULL, 'o' },
|
||||||
{ "version", 0, NULL, 'V' },
|
{ "user", 1, NULL, 'u' },
|
||||||
|
{ "userpass", 1, NULL, 'O' },
|
||||||
|
{ "version", 0, NULL, 'V' },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -197,7 +203,20 @@ static void parse_arg(int key, char *arg) {
|
||||||
opt_n_threads = v;
|
opt_n_threads = v;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'k':
|
case 1004: /* --max-cpu-usage */
|
||||||
|
v = atoi(arg);
|
||||||
|
if (v < 1 || v > 100) {
|
||||||
|
show_usage_and_exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
opt_max_cpu_usage = v;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1005: /* --safe */
|
||||||
|
opt_safe = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'k': /* --keepalive */
|
||||||
opt_keepalive = true;
|
opt_keepalive = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -227,7 +246,7 @@ static void parse_arg(int key, char *arg) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'B':
|
case 'B': /* --background */
|
||||||
opt_background = true;
|
opt_background = true;
|
||||||
opt_colors = false;
|
opt_colors = false;
|
||||||
break;
|
break;
|
||||||
|
@ -255,7 +274,7 @@ static void parse_arg(int key, char *arg) {
|
||||||
opt_colors = false;
|
opt_colors = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1003:
|
case 1003: /* --donate-level */
|
||||||
v = atoi(arg);
|
v = atoi(arg);
|
||||||
if (v < 1 || v > 99) {
|
if (v < 1 || v > 99) {
|
||||||
show_usage_and_exit(1);
|
show_usage_and_exit(1);
|
||||||
|
|
|
@ -47,6 +47,7 @@ extern bool opt_colors;
|
||||||
extern bool opt_keepalive;
|
extern bool opt_keepalive;
|
||||||
extern bool opt_background;
|
extern bool opt_background;
|
||||||
extern bool opt_double_hash;
|
extern bool opt_double_hash;
|
||||||
|
extern bool opt_safe;
|
||||||
extern char *opt_url;
|
extern char *opt_url;
|
||||||
extern char *opt_backup_url;
|
extern char *opt_backup_url;
|
||||||
extern char *opt_userpass;
|
extern char *opt_userpass;
|
||||||
|
@ -57,6 +58,7 @@ extern int opt_algo_variant;
|
||||||
extern int opt_retry_pause;
|
extern int opt_retry_pause;
|
||||||
extern int opt_retries;
|
extern int opt_retries;
|
||||||
extern int opt_donate_level;
|
extern int opt_donate_level;
|
||||||
|
extern int opt_max_cpu_usage;
|
||||||
extern int64_t opt_affinity;
|
extern int64_t opt_affinity;
|
||||||
|
|
||||||
void parse_cmdline(int argc, char *argv[]);
|
void parse_cmdline(int argc, char *argv[]);
|
||||||
|
|
Loading…
Reference in a new issue