Changeset a35b458 in mainline for uspace/app/bnchmark
- Timestamp:
- 2018-03-02T20:10:49Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
-
uspace/app/bnchmark/bnchmark.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bnchmark/bnchmark.c
r3061bc1 ra35b458 64 64 struct timeval start_time; 65 65 gettimeofday(&start_time, NULL); 66 66 67 67 errno_t rc = fn(data); 68 68 if (rc != EOK) { … … 70 70 return rc; 71 71 } 72 72 73 73 struct timeval final_time; 74 74 gettimeofday(&final_time, NULL); 75 75 76 76 /* Calculate time difference in milliseconds */ 77 77 *result = ((final_time.tv_usec - start_time.tv_usec) / 1000) + … … 84 84 char *path = (char *) data; 85 85 char *buf = malloc(BUFSIZE); 86 86 87 87 if (buf == NULL) 88 88 return ENOMEM; 89 89 90 90 FILE *file = fopen(path, "r"); 91 91 if (file == NULL) { … … 94 94 return EIO; 95 95 } 96 96 97 97 while (!feof(file)) { 98 98 fread(buf, 1, BUFSIZE, file); … … 104 104 } 105 105 } 106 106 107 107 fclose(file); 108 108 free(buf); … … 113 113 { 114 114 char *path = (char *) data; 115 115 116 116 DIR *dir = opendir(path); 117 117 if (dir == NULL) { … … 121 121 122 122 struct dirent *dp; 123 123 124 124 while ((dp = readdir(dir))) { 125 125 /* Do nothing */ 126 126 } 127 127 128 128 closedir(dir); 129 129 return EOK; … … 141 141 char *test_type = NULL; 142 142 char *endptr; 143 143 144 144 if (argc < 5) { 145 145 fprintf(stderr, NAME ": Error, argument missing.\n"); … … 147 147 return 1; 148 148 } 149 149 150 150 if (argc > 5) { 151 151 fprintf(stderr, NAME ": Error, too many arguments.\n"); … … 153 153 return 1; 154 154 } 155 155 156 156 // Skip program name 157 157 --argc; ++argv; … … 163 163 return 1; 164 164 } 165 165 166 166 --argc; ++argv; 167 167 test_type = *argv; … … 172 172 --argc; ++argv; 173 173 path = *argv; 174 174 175 175 if (str_cmp(test_type, "sequential-file-read") == 0) { 176 176 fn = sequential_read_file; … … 191 191 return 1; 192 192 } 193 193 194 194 printf("%s;%s;%s;%lu;ms\n", test_type, path, log_str, milliseconds_taken); 195 195 }
Note:
See TracChangeset
for help on using the changeset viewer.
