diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-02-18 19:42:42 -0500 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2011-02-18 19:42:42 -0500 |
| commit | 33b2ce45700e08ffdb267145ea58513631ff708d (patch) | |
| tree | 369c16f0f8bffe5371f1d0d69d7815e7d4823a41 /src | |
| parent | f97d67b869c047d09d424ca29fd725688a4970de (diff) | |
write back dirty pages and keep track of speed
Diffstat (limited to 'src')
| -rw-r--r-- | src/ftsort.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/src/ftsort.c b/src/ftsort.c index 9049dc9..5ddb48f 100644 --- a/src/ftsort.c +++ b/src/ftsort.c | |||
| @@ -18,9 +18,14 @@ | |||
| 18 | #include <stdio.h> | 18 | #include <stdio.h> |
| 19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
| 20 | #include <string.h> | 20 | #include <string.h> |
| 21 | |||
| 22 | #include <time.h> | ||
| 23 | #include <sys/time.h> | ||
| 24 | |||
| 21 | #include <errno.h> | 25 | #include <errno.h> |
| 22 | #include <unistd.h> | 26 | #include <unistd.h> |
| 23 | #include <arpa/inet.h> | 27 | #include <arpa/inet.h> |
| 28 | #include <sys/mman.h> | ||
| 24 | 29 | ||
| 25 | #include "mapping.h" | 30 | #include "mapping.h" |
| 26 | 31 | ||
| @@ -31,7 +36,17 @@ static unsigned int reordered = 0; | |||
| 31 | 36 | ||
| 32 | #define LOOK_AHEAD 1000 | 37 | #define LOOK_AHEAD 1000 |
| 33 | 38 | ||
| 34 | static struct timestamp* find_lowest_seq_no(struct timestamp* start, struct timestamp* end, | 39 | /* wall-clock time in seconds */ |
| 40 | double wctime(void) | ||
| 41 | { | ||
| 42 | struct timeval tv; | ||
| 43 | gettimeofday(&tv, NULL); | ||
| 44 | return (tv.tv_sec + 1E-6 * tv.tv_usec); | ||
| 45 | } | ||
| 46 | |||
| 47 | |||
| 48 | static struct timestamp* find_lowest_seq_no(struct timestamp* start, | ||
| 49 | struct timestamp* end, | ||
| 35 | unsigned int seqno) | 50 | unsigned int seqno) |
| 36 | { | 51 | { |
| 37 | struct timestamp *pos, *min = start; | 52 | struct timestamp *pos, *min = start; |
| @@ -139,6 +154,7 @@ int main(int argc, char** argv) | |||
| 139 | struct timestamp *ts, *end; | 154 | struct timestamp *ts, *end; |
| 140 | int swap_byte_order = 0; | 155 | int swap_byte_order = 0; |
| 141 | int opt; | 156 | int opt; |
| 157 | double start, stop; | ||
| 142 | 158 | ||
| 143 | while ((opt = getopt(argc, argv, OPTS)) != -1) { | 159 | while ((opt = getopt(argc, argv, OPTS)) != -1) { |
| 144 | switch (opt) { | 160 | switch (opt) { |
| @@ -153,6 +169,9 @@ int main(int argc, char** argv) | |||
| 153 | 169 | ||
| 154 | if (argc - optind != 1) | 170 | if (argc - optind != 1) |
| 155 | die("arguments missing"); | 171 | die("arguments missing"); |
| 172 | |||
| 173 | start = wctime(); | ||
| 174 | |||
| 156 | if (map_file_rw(argv[optind], &mapped, &size)) | 175 | if (map_file_rw(argv[optind], &mapped, &size)) |
| 157 | die("could not map file"); | 176 | die("could not map file"); |
| 158 | 177 | ||
| @@ -164,12 +183,24 @@ int main(int argc, char** argv) | |||
| 164 | restore_byte_order(ts, end); | 183 | restore_byte_order(ts, end); |
| 165 | 184 | ||
| 166 | reorder(ts, end); | 185 | reorder(ts, end); |
| 186 | |||
| 187 | /* write back */ | ||
| 188 | msync(ts, size, MS_SYNC | MS_INVALIDATE); | ||
| 189 | |||
| 190 | stop = wctime(); | ||
| 191 | |||
| 167 | fprintf(stderr, | 192 | fprintf(stderr, |
| 168 | "Total : %10d\n" | 193 | "Total : %10d\n" |
| 169 | "Holes : %10d\n" | 194 | "Holes : %10d\n" |
| 170 | "Reordered : %10d\n", | 195 | "Reordered : %10d\n" |
| 196 | "Size : %10.2f Mb\n" | ||
| 197 | "Time : %10.2f s\n" | ||
| 198 | "Throughput : %10.2f Mb/s\n", | ||
| 171 | (int) count, | 199 | (int) count, |
| 172 | holes, reordered); | 200 | holes, reordered, |
| 201 | ((double) size) / 1024.0 / 1024.0, | ||
| 202 | (stop - start), | ||
| 203 | ((double) size) / 1024.0 / 1024.0 / (stop - start)); | ||
| 173 | 204 | ||
| 174 | return 0; | 205 | return 0; |
| 175 | } | 206 | } |
