Changeset 122
- Timestamp:
- 06/03/10 05:04:09 (3 years ago)
- File:
-
- 1 edited
-
trunk/bench/bench.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bench/bench.c
r119 r122 38 38 #define GB (1024*MB) 39 39 40 #define WORKINGSET (256*MB) /* do not exceed this memory consumption */ 40 #define WORKINGSET (256*MB) /* working set for normal operation */ 41 #define WORKINGSET_H (64*MB) /* working set for hardsuite operation */ 41 42 #define NCHUNKS (32*1024) /* maximum number of chunks */ 42 #define NITER 3 /* number of iterations */43 #define NITER 3 /* number of iterations for normal operation */ 43 44 44 45 … … 103 104 sec = current.tv_sec - last.tv_sec; 104 105 usec = current.tv_usec - last.tv_usec; 105 return (float)(((double)sec + usec*1e-6)/((double)niter*nchunks)*1e6); 106 return (float)(((double)sec + usec*1e-6)); 107 } 108 109 /* Given two timeval stamps, return the time per chunk in usec */ 110 float get_usec_chunk(struct timeval last, struct timeval current) { 111 return (float)(getseconds(last, current)/(niter*nchunks)*1e6); 106 112 } 107 113 … … 182 188 } 183 189 gettimeofday(¤t, NULL); 184 tmemcpy = get seconds(last, current);190 tmemcpy = get_usec_chunk(last, current); 185 191 printf("memcpy(write):\t\t %6.1f us, %.1f MB/s\n", 186 192 tmemcpy, size/(tmemcpy*MB/1e6)); … … 193 199 } 194 200 gettimeofday(¤t, NULL); 195 tmemcpy = get seconds(last, current);201 tmemcpy = get_usec_chunk(last, current); 196 202 printf("memcpy(read):\t\t %6.1f us, %.1f MB/s\n", 197 203 tmemcpy, size/(tmemcpy*MB/1e6)); … … 208 214 } 209 215 gettimeofday(¤t, NULL); 210 tshuf = get seconds(last, current);216 tshuf = get_usec_chunk(last, current); 211 217 printf("comp(write):\t %6.1f us, %.1f MB/s\t ", 212 218 tshuf, size/(tshuf*MB/1e6)); … … 237 243 } 238 244 gettimeofday(¤t, NULL); 239 tunshuf = get seconds(last, current);245 tunshuf = get_usec_chunk(last, current); 240 246 printf("decomp(read):\t %6.1f us, %.1f MB/s\t ", 241 247 tunshuf, nbytes/(tunshuf*MB/1e6)); … … 270 276 271 277 /* Compute a sensible value for nchunks */ 272 int get_nchunks( unsigned int size_) {278 int get_nchunks(int size_, int ws) { 273 279 int nchunks; 274 280 275 nchunks = WORKINGSET/ size_;281 nchunks = ws / size_; 276 282 if (nchunks > NCHUNKS) nchunks = NCHUNKS; 277 283 if (nchunks < 1) nchunks = 1; … … 286 292 float totalsize; 287 293 int nthreads = 1; /* The number of threads */ 288 unsigned int size = 2*1024*1024;/* Buffer size */289 unsigned int elsize = 8;/* Datatype size */294 int size = 2*1024*1024; /* Buffer size */ 295 int elsize = 8; /* Datatype size */ 290 296 int rshift = 19; /* Significant bits */ 291 int j; 297 int i, j; 298 struct timeval last, current; 299 float totaltime; 292 300 293 301 if ((argc >= 2) && (strcmp(argv[1], "suite") == 0)) { … … 297 305 } 298 306 } 299 else if ((argc >= 2) && (strcmp(argv[1], "hard _suite") == 0)) {307 else if ((argc >= 2) && (strcmp(argv[1], "hardsuite") == 0)) { 300 308 hard_suite = 1; 301 309 if (argc == 3) { … … 317 325 } 318 326 if (argc >= 6) { 319 printf("Usage: bench 'suite' [nthreads] | 'hard _suite' [nthreads] | [nthreads [bufsize(KB) [typesize [sbits ]]]]\n");327 printf("Usage: bench 'suite' [nthreads] | 'hardsuite' [nthreads] | [nthreads [bufsize(KB) [typesize [sbits ]]]]\n"); 320 328 exit(1); 321 329 } 322 330 } 323 331 324 nchunks = get_nchunks(size );332 nchunks = get_nchunks(size, WORKINGSET); 325 333 326 334 if (hard_suite) { 327 for (rshift=0; rshift < 32; rshift +=5) { 328 for (elsize=1; elsize <= 32; elsize *=2) { 329 for (size=32*KB; size <= 8*MB; size *=2) { 330 nchunks = get_nchunks(size); 331 for (j=1; j <= nthreads; j++) { 332 do_bench(j, size, elsize, rshift); 333 nloops++; 335 gettimeofday(&last, NULL); 336 for (rshift = 0; rshift < 32; rshift += 5) { 337 for (elsize = 1; elsize <= 32; elsize *= 2) { 338 /* The next loop is for getting sizes that are not power of 2 */ 339 for (i = -elsize; i <= elsize; i += elsize) { 340 for (size = 32*KB; size <= 8*MB; size *= 2) { 341 nchunks = get_nchunks(size+i, WORKINGSET_H); 342 niter = 1; 343 for (j=1; j <= nthreads; j++) { 344 do_bench(j, size+i, elsize, rshift); 345 nloops++; 346 } 334 347 } 335 348 } … … 338 351 /* To compute the totalsize, we should take into account the 9 339 352 compression levels */ 340 totalsize = (1. * nloops * WORKINGSET * NITER * 9) / GB; 341 printf("Performed round-trip compr/decompr on %.1f GB", totalsize); 353 gettimeofday(¤t, NULL); 354 totalsize = (1. * nloops * (WORKINGSET_H) * NITER * 9) / GB; 355 printf("\nRound-trip compr/decompr on %.1f GB\n", totalsize); 356 totaltime = getseconds(last, current); 357 printf("Elapsed time:\t %6.1f s, %.1f MB/s\n", 358 totaltime, totalsize*KB/totaltime); 342 359 } 343 360 else if (suite) {
Note: See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/images/blosc-logo-small.png)