Changeset 1ab8539 in mainline for uspace/app
- Timestamp:
- 2014-11-14T19:16:23Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 5042706
- Parents:
- 9696b01
- Location:
- uspace/app
- Files:
-
- 8 edited
-
bnchmark/bnchmark.c (modified) (2 diffs)
-
nettest1/nettest1.c (modified) (2 diffs)
-
nettest2/nettest2.c (modified) (4 diffs)
-
stats/stats.c (modified) (1 diff)
-
tester/ipc/ping_pong.c (modified) (1 diff)
-
tester/ipc/starve.c (modified) (3 diffs)
-
testread/testread.c (modified) (3 diffs)
-
top/top.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bnchmark/bnchmark.c
r9696b01 r1ab8539 62 62 { 63 63 struct timeval start_time; 64 int rc; 65 rc = gettimeofday(&start_time, NULL); 66 if (rc != EOK) { 67 fprintf(stderr, "gettimeofday failed\n"); 68 return rc; 69 } 70 71 rc = fn(data); 64 gettimeofday(&start_time, NULL); 65 66 int rc = fn(data); 72 67 if (rc != EOK) { 73 68 fprintf(stderr, "measured function failed\n"); 74 69 return rc; 75 70 } 76 71 77 72 struct timeval final_time; 78 rc = gettimeofday(&final_time, NULL); 79 if (rc != EOK) { 80 fprintf(stderr, "gettimeofday failed\n"); 81 return rc; 82 } 73 gettimeofday(&final_time, NULL); 83 74 84 75 /* Calculate time difference in milliseconds */ … … 92 83 char *path = (char *) data; 93 84 char *buf = malloc(BUFSIZE); 94 95 if (buf == NULL) {85 86 if (buf == NULL) 96 87 return ENOMEM; 97 }98 88 99 89 FILE *file = fopen(path, "r"); -
uspace/app/nettest1/nettest1.c
r9696b01 r1ab8539 402 402 403 403 struct timeval time_before; 404 rc = gettimeofday(&time_before, NULL); 405 if (rc != EOK) { 406 fprintf(stderr, "Get time of day error %d\n", rc); 407 return rc; 408 } 404 gettimeofday(&time_before, NULL); 409 405 410 406 nettest1_test(socket_ids, 1, 1); … … 414 410 415 411 struct timeval time_after; 416 rc = gettimeofday(&time_after, NULL); 417 if (rc != EOK) { 418 fprintf(stderr, "Get time of day error %d\n", rc); 419 return rc; 420 } 412 gettimeofday(&time_after, NULL); 421 413 422 414 printf("Tested in %ld microseconds\n", tv_sub(&time_after, -
uspace/app/nettest2/nettest2.c
r9696b01 r1ab8539 356 356 357 357 struct timeval time_before; 358 rc = gettimeofday(&time_before, NULL); 359 if (rc != EOK) { 360 fprintf(stderr, "Get time of day error %d\n", rc); 361 return rc; 362 } 358 gettimeofday(&time_before, NULL); 363 359 364 360 rc = sockets_sendto_recvfrom(verbose, socket_ids, sockets, address, … … 368 364 369 365 struct timeval time_after; 370 rc = gettimeofday(&time_after, NULL); 371 if (rc != EOK) { 372 fprintf(stderr, "Get time of day error %d\n", rc); 373 return rc; 374 } 366 gettimeofday(&time_after, NULL); 375 367 376 368 if (verbose) … … 380 372 tv_sub(&time_after, &time_before)); 381 373 382 rc = gettimeofday(&time_before, NULL); 383 if (rc != EOK) { 384 fprintf(stderr, "Get time of day error %d\n", rc); 385 return rc; 386 } 374 gettimeofday(&time_before, NULL); 387 375 388 376 rc = sockets_sendto(verbose, socket_ids, sockets, address, addrlen, … … 396 384 return rc; 397 385 398 rc = gettimeofday(&time_after, NULL); 399 if (rc != EOK) { 400 fprintf(stderr, "Get time of day error %d\n", rc); 401 return rc; 402 } 386 gettimeofday(&time_after, NULL); 403 387 404 388 if (verbose) -
uspace/app/stats/stats.c
r9696b01 r1ab8539 191 191 static void print_uptime(void) 192 192 { 193 sysarg_t uptime = stats_get_uptime(); 194 printf("%s: Up %" PRIun " days, %" PRIun " hours, " 195 "%" PRIun " minutes, %" PRIun " seconds\n", NAME, 196 uptime / DAY, (uptime % DAY) / HOUR, 197 (uptime % HOUR) / MINUTE, uptime % MINUTE); 193 struct timeval uptime; 194 getuptime(&uptime); 195 196 printf("%s: Up %ld days, %ld hours, %ld minutes, %ld seconds\n", 197 NAME, uptime.tv_sec / DAY, (uptime.tv_sec % DAY) / HOUR, 198 (uptime.tv_sec % HOUR) / MINUTE, uptime.tv_sec % MINUTE); 198 199 } 199 200 -
uspace/app/tester/ipc/ping_pong.c
r9696b01 r1ab8539 43 43 44 44 struct timeval start; 45 if (gettimeofday(&start, NULL) != 0) { 46 TPRINTF("\n"); 47 return "Failed getting the time"; 48 } 45 gettimeofday(&start, NULL); 49 46 50 47 uint64_t count = 0; 51 48 while (true) { 52 49 struct timeval now; 53 if (gettimeofday(&now, NULL) != 0) { 54 TPRINTF("\n"); 55 return "Failed getting the time"; 56 } 50 gettimeofday(&now, NULL); 57 51 58 52 if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L) -
uspace/app/tester/ipc/starve.c
r9696b01 r1ab8539 40 40 const char *err = NULL; 41 41 console_ctrl_t *console = console_init(stdin, stdout); 42 if (console == NULL) {42 if (console == NULL) 43 43 return "Failed to init connection with console."; 44 }45 44 46 45 struct timeval start; 47 if (gettimeofday(&start, NULL) != 0) { 48 err = "Failed getting the time"; 49 goto leave; 50 } 46 gettimeofday(&start, NULL); 51 47 52 48 TPRINTF("Intensive computation shall be imagined (for %ds)...\n", DURATION_SECS); … … 54 50 while (true) { 55 51 struct timeval now; 56 if (gettimeofday(&now, NULL) != 0) { 57 err = "Failed getting the time"; 58 goto leave; 59 } 52 gettimeofday(&now, NULL); 60 53 61 54 if (tv_sub(&now, &start) >= DURATION_SECS * 1000000L) … … 70 63 } 71 64 } 72 65 73 66 // FIXME - unless a key was pressed, the answer leaked as no one 74 67 // will wait for it. 75 68 // We cannot use async_forget() directly, though. Something like 76 69 // console_forget_pending_kbd_event() shall come here. 77 70 78 71 TPRINTF("Terminating...\n"); 79 80 leave: 72 81 73 console_done(console); 82 74 83 75 return err; 84 76 } -
uspace/app/testread/testread.c
r9696b01 r1ab8539 123 123 struct timeval prev_time; 124 124 struct timeval start_time; 125 int rc; 126 rc = gettimeofday(&start_time, NULL); 127 if (rc != EOK) { 128 printf("gettimeofday failed\n"); 129 fclose(file); 130 free(buf); 131 return 1; 132 } 125 gettimeofday(&start_time, NULL); 133 126 prev_time = start_time; 134 127 … … 155 148 if (progress && offset >= next_mark) { 156 149 struct timeval cur_time; 157 rc = gettimeofday(&cur_time, NULL); 158 if (rc != EOK) { 159 printf("gettimeofday failed\n"); 160 fclose(file); 161 free(buf); 162 return 1; 163 } 150 gettimeofday(&cur_time, NULL); 151 164 152 uint32_t last_run = cur_time.tv_sec - prev_time.tv_sec; 165 153 uint32_t total_time = cur_time.tv_sec - start_time.tv_sec; … … 178 166 179 167 struct timeval final_time; 180 rc = gettimeofday(&final_time, NULL); 181 if (rc != EOK) { 182 printf("gettimeofday failed\n"); 183 fclose(file); 184 free(buf); 185 return 1; 186 } 168 gettimeofday(&final_time, NULL); 187 169 188 170 uint32_t total_run_time = final_time.tv_sec - start_time.tv_sec; -
uspace/app/top/top.c
r9696b01 r1ab8539 156 156 /* Get current time */ 157 157 struct timeval time; 158 if (gettimeofday(&time, NULL) != EOK) 159 return "Cannot get time of day"; 158 gettimeofday(&time, NULL); 160 159 161 160 target->hours = (time.tv_sec % DAY) / HOUR; … … 164 163 165 164 /* Get uptime */ 166 sysarg_t uptime = stats_get_uptime(); 167 target->udays = uptime / DAY; 168 target->uhours = (uptime % DAY) / HOUR; 169 target->uminutes = (uptime % HOUR) / MINUTE; 170 target->useconds = uptime % MINUTE; 165 struct timeval uptime; 166 getuptime(&uptime); 167 168 target->udays = uptime.tv_sec / DAY; 169 target->uhours = (uptime.tv_sec % DAY) / HOUR; 170 target->uminutes = (uptime.tv_sec % HOUR) / MINUTE; 171 target->useconds = uptime.tv_sec % MINUTE; 171 172 172 173 /* Get load */
Note:
See TracChangeset
for help on using the changeset viewer.
