Changeset 0d52c6f for benchmark/io/http
- Timestamp:
- Jul 17, 2020, 3:46:14 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 2ecbd7b, e93cbfa
- Parents:
- 680ae0e (diff), 53e4562 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- benchmark/io/http
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/io/http/filecache.cfa
r680ae0e r0d52c6f 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 } 58 71 59 72 struct { … … 101 114 void fill_cache( const char * path ) { 102 115 int ret; 116 ret = chdir(path); 117 if(ret < 0) { 118 abort( "chdir error: (%d) %s\n", (int)errno, strerror(errno) ); 119 } 120 103 121 size_t fcount = 0; 104 122 size_t fsize = 16; … … 118 136 raw[idx].file = strdup(fpath+2); 119 137 raw[idx].size = sb->st_size; 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) ); 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 } 123 143 } 124 144 return 0; 125 145 } 126 146 127 ret = ftw( path, walk, 10);147 ret = ftw(".", walk, 10); 128 148 if(ret < 0) { 129 149 abort( "ftw error: (%d) %s\n", (int)errno, strerror(errno) ); … … 132 152 if(fcount == 0) { 133 153 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); 134 166 } 135 167 -
benchmark/io/http/main.cfa
r680ae0e r0d52c6f 24 24 //============================================================================================= 25 25 Options options @= { 26 0, 27 42u, 28 0, 29 false, 30 false, 31 0 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; 32 33 }; 33 34 … … 70 71 {'t', "threads", "Number of worker threads to use", nworkers}, 71 72 {'b', "accept-backlog", "Maximum number of pending accepts", backlog}, 72 {'B', "channel-size", "Maximum number of accepted connection pending", chan_size} 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 73 78 }; 74 79 int opt_cnt = sizeof(opt) / sizeof(cfa_option); 75 80 76 81 char **left; 77 parse_args( argc, argv, opt, opt_cnt, "[OPTIONS] [PATH] -- cforall http server", 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 } 78 90 79 91 -
benchmark/io/http/options.hfa
r680ae0e r0d52c6f 8 8 int open_flags; 9 9 uint32_t hash_seed; 10 size_t file_cache_size; 10 size_t file_cache_size; 11 bool file_cache_list; 11 12 bool procstats; 12 13 bool viewhalts; -
benchmark/io/http/parseargs.cfa
r680ae0e r0d52c6f 12 12 13 13 extern int fprintf ( FILE * stream, const char * format, ... ); 14 extern long long int strtoll (const char* str, char** endptr, int base); 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); 15 17 } 16 18 … … 94 96 95 97 USAGE: 96 fprintf(out, " %s\n", usage);98 fprintf(out, "Usage:\n %s %s\n", argv[0], usage); 97 99 98 100 for(i; opt_count) { … … 132 134 } 133 135 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 max 141 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 max 151 152 value = r; 153 return true; 154 } 155 134 156 bool parse(const char * arg, int & value) { 135 157 char * end; -
benchmark/io/http/parseargs.hfa
r680ae0e r0d52c6f 38 38 39 39 bool parse(const char *, const char * & ); 40 bool parse(const char *, unsigned & ); 41 bool parse(const char *, size_t & ); 40 42 bool parse(const char *, int & );
Note: See TracChangeset
for help on using the changeset viewer.