Changeset fca78d4 in mainline


Ignore:
Timestamp:
2011-03-23T21:51:21Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
54e90cc
Parents:
6b3e7f7f
Message:

Enhanced testread

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/testread/testread.c

    r6b3e7f7f rfca78d4  
    7575        aoff64_t last_mark;
    7676        unsigned int i;
     77        bool check_enabled = true;
     78        bool progress = true;
    7779       
    7880        if (argc < 2) {
     
    8486        // Skip program name
    8587        --argc; ++argv;
     88       
     89        if (argc > 0 && str_cmp(*argv, "--no-check") == 0) {
     90                check_enabled = false;
     91                --argc; ++argv;
     92        }
     93       
     94        if (argc > 0 && str_cmp(*argv, "--no-progress") == 0) {
     95                progress = false;
     96                --argc; ++argv;
     97        }
    8698       
    8799        if (argc != 1) {
     
    131143               
    132144                for (i = 0; i < elems; i++) {
    133                         if (uint64_t_le2host(buf[i]) != expected) {
     145                        if (check_enabled && uint64_t_le2host(buf[i]) != expected) {
    134146                                printf("Unexpected value at offset %" PRIuOFF64 "\n", offset);
    135147                                fclose(file);
     
    141153                }
    142154               
    143                 if (offset >= next_mark) {
     155                if (progress && offset >= next_mark) {
    144156                        struct timeval cur_time;
    145157                        rc = gettimeofday(&cur_time, NULL);
     
    165177        }
    166178       
     179        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        }
     187       
     188        uint32_t total_run_time = final_time.tv_sec - start_time.tv_sec;
     189        if (total_run_time > 0) {
     190                printf("total bytes: %" PRIuOFF64
     191                    ", total time: %u s, avg speed: %" PRIuOFF64 " B/s\n",
     192                    offset,
     193                    total_run_time,
     194                    offset/total_run_time);
     195        }
     196       
    167197        fclose(file);
    168198        free(buf);
Note: See TracChangeset for help on using the changeset viewer.