From 07c119d290526a0ab40d0bbf9ab97d676ab1a43c Mon Sep 17 00:00:00 2001 From: josh Date: Mon, 13 Oct 2008 22:22:03 +0000 Subject: [PATCH] floyd.cc -> floyd-sequential.cc git-svn-id: svn://anubis/gvsu@196 45c1a28c-8058-47b2-ae61-ca45b979098e --- cs677/hw7/src/Makefile | 2 +- cs677/hw7/src/{floyd.cc => floyd-sequential.cc} | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) rename cs677/hw7/src/{floyd.cc => floyd-sequential.cc} (83%) diff --git a/cs677/hw7/src/Makefile b/cs677/hw7/src/Makefile index 1ca8454..dc4a788 100644 --- a/cs677/hw7/src/Makefile +++ b/cs677/hw7/src/Makefile @@ -1,6 +1,6 @@ TARGETS := gen_adj_matrix -TARGETS += floyd +TARGETS += floyd-sequential CXXFLAGS := -fopenmp diff --git a/cs677/hw7/src/floyd.cc b/cs677/hw7/src/floyd-sequential.cc similarity index 83% rename from cs677/hw7/src/floyd.cc rename to cs677/hw7/src/floyd-sequential.cc index 26d9920..f1effab 100644 --- a/cs677/hw7/src/floyd.cc +++ b/cs677/hw7/src/floyd-sequential.cc @@ -13,6 +13,7 @@ #include #include #include +#include /* gettimeofday(), struct timeval */ using namespace std; void usage(char * progname); @@ -36,6 +37,9 @@ int main(int argc, char * argv[]) int D[2][num_verts][num_verts]; convertToMatrix(v, num_verts, (int *) &D[0]); + struct timeval before, after; + gettimeofday(&before, NULL); /* Start timing */ + /* Run Floyd's Algorithm on D */ for (int k = 1; k <= num_verts; k++) { @@ -58,6 +62,8 @@ int main(int argc, char * argv[]) } } + gettimeofday(&after, NULL); /* Stop timing */ + cout << "Result:" << endl; /* Print out the final matrix */ for (int i = 0; i < num_verts; i++) { @@ -71,6 +77,11 @@ int main(int argc, char * argv[]) printf("\n"); } + double time_before = before.tv_sec + before.tv_usec / 1000000.0; + double time_after = after.tv_sec + after.tv_usec / 1000000.0; + double diff = time_after - time_before; + cout << "Elapsed time: " << diff << " seconds." << endl; + return 0; }