summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/precedent.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/precedent.c b/src/precedent.c
index 1874c51..c623234 100644
--- a/src/precedent.c
+++ b/src/precedent.c
@@ -2,6 +2,7 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
+#include <time.h>
#include <libgen.h>
#include "precedent.h"
#include "hashtable.h"
@@ -9,7 +10,9 @@
#include "eval.h"
int main(int argc, char** argv) {
+ clock_t initTime = clock();
int visual = 0;
+ int debug = 0;
if (argc > 1) {
for (int i = 1; i < argc; i++) {
if (strcmp("--version", argv[i]) == 0) {
@@ -25,6 +28,9 @@ int main(int argc, char** argv) {
else if (strcmp("--visualize", argv[i]) == 0) {
visual = 1;
}
+ else if (strcmp("--debug", argv[i]) == 0) {
+ debug = 1;
+ }
}
}
else {
@@ -50,7 +56,13 @@ int main(int argc, char** argv) {
printf("--END VISUALIZATION--\n");
}
hashtable_t* rootTable = init_hashtable(500, NULL);
+ clock_t setupTime = clock();
sym_t* sym = eval(finalSymbol, rootTable);
+ clock_t evalTime = clock();
+ if (debug) {
+ printf("time taken to set up environment: %.5f secs\n", (float)(setupTime - initTime) / (float)CLOCKS_PER_SEC);
+ printf("time taken to execute program: %.5f secs\n", ((float)(evalTime - setupTime) - initTime) / (float)CLOCKS_PER_SEC);
+ }
destroy_sym(sym);
destroy_sym_tree(finalSymbol);
destroy_hashtable(rootTable);