summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2016-11-28 15:02:33 -0700
committerAaron Ball <nullspoon@oper.io>2016-11-28 15:02:38 -0700
commitb24df58e244ba5eb84749fc1985a8ddd5bc3f206 (patch)
tree1531f206180cbd03c5b20052dde366a5533928a0
parentffa29bb57ff5555d2aab7d2b1750e8ff10c99d73 (diff)
parent7be0c13884b2a220e1d90a4ef6ce1c3f2690dcbe (diff)
downloadpalindrome_finder-b24df58e244ba5eb84749fc1985a8ddd5bc3f206.tar.gz
palindrome_finder-b24df58e244ba5eb84749fc1985a8ddd5bc3f206.tar.xz
Merge branch 'timer-fix'HEADmaster
Signed-off-by: Aaron Ball <nullspoon@oper.io>
-rw-r--r--src/main.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/main.c b/src/main.c
index 479c48b..69f297e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -160,11 +160,11 @@ int main(int argc, char *argv[]) {
free(data);
- // Calculate runtime
- long int secs = stop.tv_sec - start.tv_sec;
- long int nano = stop.tv_nsec - start.tv_nsec;
+ // Calculate search time
+ double timestart = start.tv_sec + (1.0e-9 * start.tv_nsec);
+ double timestop = stop.tv_sec + (1.0e-9 * stop.tv_nsec);
// Print runtime message
- printf("Palindrome search took %ld.%ld seconds\n", secs, nano / 10000);
+ printf("Palindrome search took %.5f seconds\n", timestop - timestart);
return 0;
}

Generated by cgit