Skip to content

Commit 81acf48

Browse files
committed
Fix OpenMP and MPI timing errors by removing incorrect CLOCKS_PER_SEC division and updating format specifiers, closes #48
1 parent 38397a6 commit 81acf48

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

QPEMPI.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,15 @@ int main(int argc, char *argv[]) {
297297
if (parsed.num_values != 12) {
298298
printf("Error: INSERT requires exactly 12 values.\n");
299299
} else if (success) {
300-
printf("Insert successful. Execution Time: %ld\n\n", (long)execTime);
300+
printf("Insert successful. Execution Time: %.4f seconds\n\n", execTime);
301301
} else {
302-
printf("Insert failed. Execution Time: %ld\n\n", (long)execTime);
302+
printf("Insert failed. Execution Time: %.4f seconds\n\n", execTime);
303303
}
304304
} else if (parsed.command == CMD_DELETE) {
305305
if (result) {
306-
printf("Delete successful. Rows affected: %d. Execution Time: %ld\n\n", rowsAffected, (long)execTime);
306+
printf("Delete successful. Rows affected: %d. Execution Time: %.4f seconds\n\n", rowsAffected, execTime);
307307
} else {
308-
printf("Delete failed. Execution Time: %ld\n\n", (long)execTime);
308+
printf("Delete failed. Execution Time: %.4f seconds\n\n", execTime);
309309
}
310310
} else if (parsed.command == CMD_SELECT) {
311311
printTable(NULL, result, ROW_LIMIT);

QPEOMP.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ int main(int argc, char *argv[]) {
169169
#pragma omp barrier
170170

171171
// End timer for engine initialization
172-
double initTimeTaken = ((double)omp_get_wtime() - totalStart) / CLOCKS_PER_SEC;
172+
double initTimeTaken = omp_get_wtime() - totalStart;
173173

174174
// Load the COMMANDS into memory (from COMMAND text file)
175175
const char *query_file = "sample-queries.txt";
@@ -203,7 +203,7 @@ int main(int argc, char *argv[]) {
203203
fclose(fp);
204204

205205
// End timer for loading queries
206-
double loadTimeTaken = ((double)omp_get_wtime() - totalStart) / CLOCKS_PER_SEC;
206+
double loadTimeTaken = omp_get_wtime() - totalStart;
207207

208208
// Split queries into an array to avoid strtok race conditions
209209
#define MAX_QUERIES 1000
@@ -279,7 +279,7 @@ int main(int argc, char *argv[]) {
279279
free_where_clause_list(whereClause);
280280
}
281281

282-
execTime = (double)(omp_get_wtime() - start) / CLOCKS_PER_SEC;
282+
execTime = omp_get_wtime() - start;
283283
} else {
284284
parseFailed = true;
285285
}
@@ -296,15 +296,15 @@ int main(int argc, char *argv[]) {
296296
if (parsed.num_values != 12) {
297297
printf("Error: INSERT requires exactly 12 values.\n");
298298
} else if (success) {
299-
printf("Insert successful. Execution Time: %ld\n\n", (long)execTime);
299+
printf("Insert successful. Execution Time: %.4f seconds\n\n", execTime);
300300
} else {
301-
printf("Insert failed. Execution Time: %ld\n\n", (long)execTime);
301+
printf("Insert failed. Execution Time: %.4f seconds\n\n", execTime);
302302
}
303303
} else if (parsed.command == CMD_DELETE) {
304304
if (result) {
305-
printf("Delete successful. Rows affected: %d. Execution Time: %ld\n\n", rowsAffected, (long)execTime);
305+
printf("Delete successful. Rows affected: %d. Execution Time: %.4f seconds\n\n", rowsAffected, execTime);
306306
} else {
307-
printf("Delete failed. Execution Time: %ld\n\n", (long)execTime);
307+
printf("Delete failed. Execution Time: %.4f seconds\n\n", execTime);
308308
}
309309
} else if (parsed.command == CMD_SELECT) {
310310
printTable(NULL, result, ROW_LIMIT);
@@ -325,7 +325,7 @@ int main(int argc, char *argv[]) {
325325
destroyEngineOMP(engine);
326326

327327
// Print total runtime statistics in pretty colors
328-
double totalTimeTaken = ((double)omp_get_wtime() - totalStart) / CLOCKS_PER_SEC;
328+
double totalTimeTaken = omp_get_wtime() - totalStart;
329329
printf(CYAN "======= Execution Summary =======" RESET "\n");
330330
printf(CYAN "Engine Initialization Time: " RESET YELLOW "%.4f seconds\n" RESET, initTimeTaken);
331331
printf(CYAN "Query Loading Time: " RESET YELLOW "%.4f seconds\n" RESET, loadTimeTaken - initTimeTaken);

0 commit comments

Comments
 (0)