#include "threads-model.h"
#include "clockvector.h"
#include "execution.h"
+#include <sys/time.h>
+
SCAnalysis::SCAnalysis() :
cvmap(),
threadlists(1),
execution(NULL),
print_always(false),
- print_buggy(true)
+ print_buggy(true),
+ time(false),
+ stats((struct sc_statistics *)model_calloc(1, sizeof(struct sc_statistics)))
{
}
SCAnalysis::~SCAnalysis() {
+ delete(stats);
}
void SCAnalysis::setExecution(ModelExecution * execution) {
return name;
}
+void SCAnalysis::finish() {
+ if (time)
+ model_print("Elapsed time in usec %llu\n", stats->elapsedtime);
+}
+
bool SCAnalysis::option(char * opt) {
if (strcmp(opt, "verbose")==0) {
print_always=true;
} else if (strcmp(opt, "quiet")==0) {
print_buggy=false;
return false;
- } if (strcmp(opt, "help") != 0) {
+ } 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("verbose -- print all feasible executions\n");
model_print("buggy -- print only buggy executions (default)\n");
model_print("quiet -- print nothing\n");
+ model_print("time -- time execution of scanalysis\n");
model_print("\n");
return true;
}
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()))
print_list(list);
+ if (time) {
+ gettimeofday(&finish, NULL);
+ stats->elapsedtime+=((finish.tv_sec*1000000+finish.tv_usec)-(start.tv_sec*1000000+start.tv_usec));
+ }
}
void SCAnalysis::check_rf(action_list_t *list) {
#include "traceanalysis.h"
#include "hashtable.h"
+struct sc_statistics {
+ unsigned long long elapsedtime;
+};
+
class SCAnalysis : public TraceAnalysis {
public:
SCAnalysis();
virtual void analyze(action_list_t *);
virtual const char * name();
virtual bool option(char *);
+ virtual void finish();
+
SNAPSHOTALLOC
private:
ModelExecution *execution;
bool print_always;
bool print_buggy;
+ bool time;
+ struct sc_statistics *stats;
};
#endif
class TraceAnalysis {
public:
+ /** setExecution is called once after installation with a reference to
+ * the ModelExecution object. */
+
virtual void setExecution(ModelExecution * execution) = 0;
+
+ /** analyze is called once for each feasible trace with the complete
+ * action_list object. */
+
virtual void analyze(action_list_t *) = 0;
+
+ /** name returns the analysis name string */
+
virtual const char * name() = 0;
+
+ /** Each analysis option is passed into the option method. This
+ * occurs before installation (i.e., you don't have a
+ * ModelExecution object yet). A TraceAnalysis object should
+ * support the option "help" */
+
virtual bool option(char *) = 0;
+ /** The finish method is called once at the end. This should be
+ * used to print out results. */
+
+ virtual void finish() = 0;
+
SNAPSHOTALLOC
};
#endif