Changes in / [e93cbfa:eacf82c]
- Files:
-
- 6 edited
-
benchmark/io/http/filecache.cfa (modified) (4 diffs)
-
benchmark/io/http/main.cfa (modified) (2 diffs)
-
benchmark/io/http/options.hfa (modified) (1 diff)
-
benchmark/io/http/parseargs.cfa (modified) (3 diffs)
-
benchmark/io/http/parseargs.hfa (modified) (1 diff)
-
src/Common/PassVisitor.proto.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/filecache.cfa
re93cbfa reacf82c 56 56 } 57 57 58 static inline [unsigned size, char unit] human_size( size_t size ) {59 int idx = 0;60 static char units [] = { ' ', 'K', 'M', 'G', 'T' };61 while( size >= 1024 ) {62 idx++;63 size /= 1024;64 if(idx >= 5) {65 abort("File too large to print\n");66 }67 }68 69 return [size, units[idx]];70 }71 58 72 59 struct { … … 114 101 void fill_cache( const char * path ) { 115 102 int ret; 116 ret = chdir(path);117 if(ret < 0) {118 abort( "chdir error: (%d) %s\n", (int)errno, strerror(errno) );119 }120 121 103 size_t fcount = 0; 122 104 size_t fsize = 16; … … 136 118 raw[idx].file = strdup(fpath+2); 137 119 raw[idx].size = sb->st_size; 138 if( !options.file_cache_list ) { 139 raw[idx].fd = open( fpath, options.open_flags ); 140 if(raw[idx].fd < 0) { 141 abort( "open file error: (%d) %s\n", (int)errno, strerror(errno) ); 142 } 120 raw[idx].fd = open( fpath, options.open_flags ); 121 if(raw[idx].fd < 0) { 122 abort( "open file error: (%d) %s\n", (int)errno, strerror(errno) ); 143 123 } 144 124 return 0; 145 125 } 146 126 147 ret = ftw( ".", walk, 10);127 ret = ftw(path, walk, 10); 148 128 if(ret < 0) { 149 129 abort( "ftw error: (%d) %s\n", (int)errno, strerror(errno) ); … … 152 132 if(fcount == 0) { 153 133 abort("No file found in path %s\n", path); 154 }155 156 if(options.file_cache_list) {157 printf("Listing files and exiting\n");158 for(i; fcount) {159 int s; char u;160 [s, u] = human_size(raw[i].size);161 printf("%4d%c - %s\n", s, u, raw[i].file);162 free(raw[i].file);163 }164 free(raw);165 exit(0);166 134 } 167 135 -
benchmark/io/http/main.cfa
re93cbfa reacf82c 24 24 //============================================================================================= 25 25 Options options @= { 26 0, // open_flags; 27 42u, // hash_seed; 28 0, // file_cache_size; 29 false, // file_cache_list; 30 false, // procstats; 31 false, // viewhalts; 32 0 // the_cluster; 26 0, 27 42u, 28 0, 29 false, 30 false, 31 0 33 32 }; 34 33 … … 71 70 {'t', "threads", "Number of worker threads to use", nworkers}, 72 71 {'b', "accept-backlog", "Maximum number of pending accepts", backlog}, 73 {'B', "channel-size", "Maximum number of accepted connection pending", chan_size}, 74 {'S', "seed", "seed to use for hashing", options.hash_seed }, 75 {'C', "cache-size", "Size of the cache to use, if set to small, will uses closes power of 2", options.file_cache_size }, 76 {'l', "list-files", "List the files in the specified path and exit", options.file_cache_list, parse_settrue } 77 72 {'B', "channel-size", "Maximum number of accepted connection pending", chan_size} 78 73 }; 79 74 int opt_cnt = sizeof(opt) / sizeof(cfa_option); 80 75 81 76 char **left; 82 parse_args( argc, argv, opt, opt_cnt, "[OPTIONS]... [PATH]\ncforall http server", left ); 83 if( left[0] != 0p ) { 84 path = left[0]; 85 left++; 86 } 87 if( left[0] != 0p ) { 88 abort("Too many trailing arguments!\n"); 89 } 77 parse_args( argc, argv, opt, opt_cnt, "[OPTIONS] [PATH] -- cforall http server", left ); 90 78 91 79 -
benchmark/io/http/options.hfa
re93cbfa reacf82c 8 8 int open_flags; 9 9 uint32_t hash_seed; 10 size_t file_cache_size; 11 bool file_cache_list; 10 size_t file_cache_size; 12 11 bool procstats; 13 12 bool viewhalts; -
benchmark/io/http/parseargs.cfa
re93cbfa reacf82c 12 12 13 13 extern int fprintf ( FILE * stream, const char * format, ... ); 14 15 extern long long int strtoll (const char* str, char** endptr, int base); 16 extern unsigned long long int strtoull(const char* str, char** endptr, int base); 14 extern long long int strtoll (const char* str, char** endptr, int base); 17 15 } 18 16 … … 96 94 97 95 USAGE: 98 fprintf(out, " Usage:\n %s %s\n", argv[0], usage);96 fprintf(out, "%s\n", usage); 99 97 100 98 for(i; opt_count) { … … 134 132 } 135 133 136 bool parse(const char * arg, unsigned & value) {137 char * end;138 unsigned long long int r = strtoull(arg, &end, 10);139 if(*end != '\0') return false;140 #warning not checking max141 142 value = r;143 return true;144 }145 146 bool parse(const char * arg, size_t & value) {147 char * end;148 unsigned long long int r = strtoull(arg, &end, 10);149 if(*end != '\0') return false;150 #warning not checking max151 152 value = r;153 return true;154 }155 156 134 bool parse(const char * arg, int & value) { 157 135 char * end; -
benchmark/io/http/parseargs.hfa
re93cbfa reacf82c 38 38 39 39 bool parse(const char *, const char * & ); 40 bool parse(const char *, unsigned & );41 bool parse(const char *, size_t & );42 40 bool parse(const char *, int & ); -
src/Common/PassVisitor.proto.h
re93cbfa reacf82c 38 38 }; 39 39 40 std::stack< cleanup_t , std::vector< cleanup_t >> cleanups;40 std::stack< cleanup_t > cleanups; 41 41 }; 42 42
Note:
See TracChangeset
for help on using the changeset viewer.