Skip to content

Commit

Permalink
Added cores to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
merendamattia committed Feb 26, 2024
1 parent 0633e04 commit 9ede2e1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ This command will initiate the analysis process for the specified smart contract
Options:
-a,--address <arg> address of an Ethereum smart contract
-b,--benchmark <arg> filepath of the benchmark
-C,--cores <arg> number of cores used
-c,--dump-cfg dump the CFG
-d,--dump-analysis <arg> dump the analysis (html, dot)
-f,--filepath <arg> filepath of the Etherem smart contract
Expand Down
36 changes: 23 additions & 13 deletions src/main/java/it/unipr/EVMLiSA.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class EVMLiSA {
private int numberOfAPIEtherscanRequest = 0;
private int numberOfAPIEtherscanRequestOnSuccess = 0;
private static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss,SSS");
private final int CORES = 1; // Runtime.getRuntime().availableProcessors();
private int CORES;
private long startOfExecutionTime = 0;

/**
Expand Down Expand Up @@ -106,6 +106,10 @@ private void go(String[] args) throws Exception {
Option benchmarkOption = new Option("b", "benchmark", true, "filepath of the benchmark");
benchmarkOption.setRequired(false);
options.addOption(benchmarkOption);

Option coresOption = new Option("C", "cores", true, "number of cores used");
coresOption.setRequired(false);
options.addOption(coresOption);

// Boolean parameters
Option dumpStatisticsOption = Option.builder("s")
Expand Down Expand Up @@ -145,31 +149,37 @@ private void go(String[] args) throws Exception {
String stackSize = cmd.getOptionValue("stack-size");
String stackSetSize = cmd.getOptionValue("stack-set-size");
String benchmark = cmd.getOptionValue("benchmark");

if (benchmark != null) {
Files.createDirectories(Paths.get(OUTPUT_DIR));
SMARTCONTRACTS_FULLPATH = benchmark;
try {
runBenchmark();
} catch (FileNotFoundException e) {
System.err.println("File " + benchmark + " not found.");
}
return;
}
String coresOpt = cmd.getOptionValue("cores");

if (coresOpt != null && Integer.parseInt(coresOpt) > 0)
CORES = Integer.parseInt(coresOpt);
else
CORES = 1;

try {
if (stackSize != null && Integer.parseInt(stackSize) > 0)
AbstractStack.setStackLimit(Integer.parseInt(stackSize));

if (stackSetSize != null && Integer.parseInt(stackSetSize) > 0)
AbstractStackSet.setStackSetSize(Integer.parseInt(stackSetSize));

} catch (NumberFormatException e) {
System.out.println("Size must be an integer");
formatter.printHelp("help", options);

System.exit(1);
}

if (benchmark != null) {
Files.createDirectories(Paths.get(OUTPUT_DIR));
SMARTCONTRACTS_FULLPATH = benchmark;
try {
runBenchmark();
} catch (FileNotFoundException e) {
System.err.println("File " + benchmark + " not found.");
}
return;
}

if (addressSC == null && filepath == null) {
// Error: no address and no filepath
Expand Down

0 comments on commit 9ede2e1

Please sign in to comment.