X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=scanalysis.cc;h=17763870814aeac14e528bcef8aa7b02e902e947;hb=2d0d4ac38e05905a6633b3f2d5112ccadd45c27f;hp=13aada1a8fee202149f11b94b8ab3a9078971d39;hpb=a4d3f2ae3f3a9e2a30cc36c92cee9f83bb09e9b1;p=model-checker.git diff --git a/scanalysis.cc b/scanalysis.cc index 13aada1..1776387 100644 --- a/scanalysis.cc +++ b/scanalysis.cc @@ -3,6 +3,8 @@ #include "threads-model.h" #include "clockvector.h" #include "execution.h" +#include + SCAnalysis::SCAnalysis() : cvmap(), @@ -12,11 +14,15 @@ SCAnalysis::SCAnalysis() : threadlists(1), execution(NULL), print_always(false), - print_buggy(true) + print_buggy(true), + print_nonsc(false), + time(false), + stats((struct sc_statistics *)model_calloc(1, sizeof(struct sc_statistics))) { } SCAnalysis::~SCAnalysis() { + delete(stats); } void SCAnalysis::setExecution(ModelExecution * execution) { @@ -28,6 +34,13 @@ const char * SCAnalysis::name() { return name; } +void SCAnalysis::finish() { + if (time) + model_print("Elapsed time in usec %llu\n", stats->elapsedtime); + model_print("SC count: %u\n", stats->sccount); + model_print("Non-SC count: %u\n", stats->nonsccount); +} + bool SCAnalysis::option(char * opt) { if (strcmp(opt, "verbose")==0) { print_always=true; @@ -37,14 +50,22 @@ bool SCAnalysis::option(char * opt) { } else if (strcmp(opt, "quiet")==0) { print_buggy=false; return false; - } if (strcmp(opt, "help") != 0) { + } else if (strcmp(opt, "nonsc")==0) { + print_nonsc=true; + return false; + } else if (strcmp(opt, "time")==0) { + time=true; + return false; + } else if (strcmp(opt, "help") != 0) { model_print("Unrecognized option: %s\n", opt); } model_print("SC Analysis options\n"); model_print("verbose -- print all feasible executions\n"); model_print("buggy -- print only buggy executions (default)\n"); + model_print("nonsc -- print non-sc execution\n"); model_print("quiet -- print nothing\n"); + model_print("time -- time execution of scanalysis\n"); model_print("\n"); return true; @@ -73,10 +94,28 @@ void SCAnalysis::print_list(action_list_t *list) { } void SCAnalysis::analyze(action_list_t *actions) { + + struct timeval start; + struct timeval finish; + if (time) + gettimeofday(&start, NULL); action_list_t *list = generateSC(actions); check_rf(list); - if (print_always || (print_buggy && execution->have_bug_reports())) + if (print_always || (print_buggy && execution->have_bug_reports())|| (print_nonsc && cyclic)) print_list(list); + if (time) { + gettimeofday(&finish, NULL); + stats->elapsedtime+=((finish.tv_sec*1000000+finish.tv_usec)-(start.tv_sec*1000000+start.tv_usec)); + } + update_stats(); +} + +void SCAnalysis::update_stats() { + if (cyclic) { + stats->nonsccount++; + } else { + stats->sccount++; + } } void SCAnalysis::check_rf(action_list_t *list) {