#define NI_FLAGS_PRINT_CMD 0x0200
#define NI_FLAGS_SKIP_RO_APP 0x0400
#define NI_FLAGS_RM_ORIGIN_AFTER_NI 0x0800
+#define NI_FLAGS_SET_PRIORITY 0x1000
typedef std::function<void (std::string)> afterCreate;
std::vector<std::string> extraRefPath;
std::vector<std::string> inputBubbleRefFiles;
std::vector<std::string> mibcPath;
+ int priority;
} NIOption;
/**
*/
ni_error_e regenerateTACNI(NIOption* opt);
+/**
+ * @brief Sets the priority of the process to the specified values from -20 to 19.(default : 0)
+ */
+void setPriority(NIOption* opt);
+
#endif /* __NI_COMMON_H__ */
" (This option works with --ni-regen-all-app only)\n"
" --rm-origin-after-ni - Remove original dll after creating native image\n"
" Note!: App ATOC options(--ni-pkg, --ni-regen-all-app, --tac-regen-all) cannot be used with --rm-origin-after-ni option.\n"
- " (Use only for assemblies that will not be AOTed again afterward.)"
+ " (Use only for assemblies that will not be AOTed again afterward.)\n"
+ " --set-priority - Sets the priority of the process to the specified values from -20(highest priority) to 19(lowest priority).(default : 0)\n"
+
"\n"
"Usage: dotnettool [options] [command] [arguments]\n"
"\n"
opt->flags |= NI_FLAGS_SKIP_RO_APP;
} else if (arg == "--rm-origin-after-ni") {
opt->flags |= NI_FLAGS_RM_ORIGIN_AFTER_NI;
+ } else if (arg == "--set-priority") {
+ ++i;
+ if (i >= argc) {
+ _SOUT("Priority value(-20 ~ 19) should be followed for --set-priority option");
+ DisplayUsage();
+ return 0;
+ }
+
+ opt->flags |= NI_FLAGS_SET_PRIORITY;
+ try {
+ opt->priority = std::stoi(argv[i]);
+ setPriority(opt);
+ } catch (...) {
+ _SERR("Invalid argument: %s", argv[i]);
+ DisplayUsage();
+ return 0;
+ }
} else if (arg == "--mibc") {
++i;
if (i >= argc) {
gettimeofday(&tv, NULL);
endtime = tv.tv_sec * 1000l + tv.tv_usec / 1000l;
- _SOUT("\nSpend time for dotnettool is [%d]ms", (int)(endtime - starttime));
+ int ms = (int)(endtime - starttime);
+ float sec = (float)(ms/1000);
+ _SOUT("\nSpend time for dotnettool is [%d]ms, [%.3f]sec", ms, sec);
return 0;
}
#include <wait.h>
#include <dirent.h>
#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include <algorithm>
#include <string>
return NI_ERROR_NONE;
}
+void setPriority(NIOption* opt)
+{
+ pid_t pid = getpid();
+ if (setpriority(PRIO_PROCESS, pid, opt->priority) == 0) {
+ std::string str = " ";
+ if (opt->priority <= -20) {
+ str = " highest ";
+ } else if (opt->priority >= 19) {
+ str = " lowest ";
+ }
+ _SOUT("Success to set the%spriority of the process. pid : [%d], priority : [%d]", str.c_str(), pid, getpriority(PRIO_PROCESS, pid));
+ } else {
+ _SERR("Failed to set the priority of the process. pid : [%d], priority : [%d]", pid, getpriority(PRIO_PROCESS, pid));
+ }
+}
+
static ni_error_e crossgen2PipeLine(const std::vector<std::string>& dllList, const std::vector<std::string>& refPaths, NIOption* opt)
{
// fork crossgen2
return NI_ERROR_ABNORMAL_PROCESS_TERMINATION;
}
} else {
+ if (opt->flags & NI_FLAGS_SET_PRIORITY) {
+ setPriority(opt);
+ }
std::vector<const char*> argv;
makeArgs(argv, refPaths, opt);
argv.push_back(CROSSGEN_OPT_OUT_NEAR_INPUT);
return NI_ERROR_ABNORMAL_PROCESS_TERMINATION;
}
} else {
+ if (opt->flags & NI_FLAGS_SET_PRIORITY) {
+ setPriority(opt);
+ }
std::vector<const char*> argv;
makeArgs(argv, refPaths, opt);