|
31 | 31 |
|
32 | 32 | #defineWRITE_SIZE(8 * 1024)/* 8k */
|
33 | 33 |
|
34 |
| -#defineLABEL_FORMAT" %-32s" |
35 |
| -#defineNA_FORMATLABEL_FORMAT "%18s" |
| 34 | +#defineLABEL_FORMAT" %-32s" |
| 35 | +#defineNA_FORMATLABEL_FORMAT "%18s" |
36 | 36 |
|
37 | 37 |
|
38 | 38 | intops_per_test=2000;
|
@@ -365,19 +365,19 @@ test_sync(int writes_per_op)
|
365 | 365 | * If O_DIRECT is enabled, test that with open_sync
|
366 | 366 | */
|
367 | 367 | #ifPG_O_DIRECT!=0
|
368 |
| -if (writes_per_op==1) |
369 |
| -printf(LABEL_FORMAT,"open_sync 8k direct I/O write"); |
370 |
| -else |
371 |
| -printf(LABEL_FORMAT,"2 open_sync 8k direct I/O writes"); |
372 |
| -fflush(stdout); |
373 |
| - |
374 | 368 | if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG |PG_O_DIRECT,0))==-1)
|
375 | 369 | {
|
376 | 370 | printf(NA_FORMAT,"o_direct","n/a**\n");
|
377 | 371 | fs_warning= true;
|
378 | 372 | }
|
379 | 373 | else
|
380 | 374 | {
|
| 375 | +if (writes_per_op==1) |
| 376 | +printf(LABEL_FORMAT,"open_sync 8k direct I/O write"); |
| 377 | +else |
| 378 | +printf(LABEL_FORMAT,"2 open_sync 8k direct I/O writes"); |
| 379 | +fflush(stdout); |
| 380 | + |
381 | 381 | gettimeofday(&start_t,NULL);
|
382 | 382 | for (ops=0;ops<ops_per_test;ops++)
|
383 | 383 | {
|
@@ -423,47 +423,51 @@ test_open_syncs(void)
|
423 | 423 | printf("(This is designed to compare the cost of one large\n");
|
424 | 424 | printf("sync'ed write and two smaller sync'ed writes.)\n");
|
425 | 425 |
|
426 |
| -/* XXX no PG_O_DIRECT */ |
427 |
| - |
428 | 426 | /*
|
429 | 427 | * Test open_sync with different size files
|
430 | 428 | */
|
431 | 429 | #ifdefOPEN_SYNC_FLAG
|
432 |
| -printf(LABEL_FORMAT,"open_sync 16k write"); |
433 |
| -fflush(stdout); |
434 |
| - |
435 |
| -if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG,0))==-1) |
436 |
| -die("Cannot open output file."); |
437 |
| -gettimeofday(&start_t,NULL); |
438 |
| -for (ops=0;ops<ops_per_test;ops++) |
| 430 | +if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG |PG_O_DIRECT,0))==-1) |
| 431 | +printf(NA_FORMAT,"o_direct","n/a**\n"); |
| 432 | +else |
439 | 433 | {
|
440 |
| -if (write(tmpfile,buf,WRITE_SIZE*2)!=WRITE_SIZE*2) |
441 |
| -die("write failed"); |
442 |
| -if (lseek(tmpfile,0,SEEK_SET)==-1) |
443 |
| -die("seek failed"); |
444 |
| -} |
445 |
| -gettimeofday(&stop_t,NULL); |
446 |
| -close(tmpfile); |
447 |
| -print_elapse(start_t,stop_t); |
448 |
| - |
449 |
| -printf(LABEL_FORMAT,"2 open_sync 8k writes"); |
450 |
| -fflush(stdout); |
| 434 | +printf(LABEL_FORMAT,"open_sync 16k write"); |
| 435 | +fflush(stdout); |
451 | 436 |
|
452 |
| -if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG,0))==-1) |
453 |
| -die("Cannot open output file."); |
454 |
| -gettimeofday(&start_t,NULL); |
455 |
| -for (ops=0;ops<ops_per_test;ops++) |
| 437 | +gettimeofday(&start_t,NULL); |
| 438 | +for (ops=0;ops<ops_per_test;ops++) |
| 439 | +{ |
| 440 | +if (write(tmpfile,buf,WRITE_SIZE*2)!=WRITE_SIZE*2) |
| 441 | +die("write failed"); |
| 442 | +if (lseek(tmpfile,0,SEEK_SET)==-1) |
| 443 | +die("seek failed"); |
| 444 | +} |
| 445 | +gettimeofday(&stop_t,NULL); |
| 446 | +close(tmpfile); |
| 447 | +print_elapse(start_t,stop_t); |
| 448 | +} |
| 449 | + |
| 450 | +if ((tmpfile=open(filename,O_RDWR |OPEN_SYNC_FLAG |PG_O_DIRECT,0))==-1) |
| 451 | +printf(NA_FORMAT,"n/a**\n"); |
| 452 | +else |
456 | 453 | {
|
457 |
| -if (write(tmpfile,buf,WRITE_SIZE)!=WRITE_SIZE) |
458 |
| -die("write failed"); |
459 |
| -if (write(tmpfile,buf,WRITE_SIZE)!=WRITE_SIZE) |
460 |
| -die("write failed"); |
461 |
| -if (lseek(tmpfile,0,SEEK_SET)==-1) |
462 |
| -die("seek failed"); |
| 454 | +printf(LABEL_FORMAT,"2 open_sync 8k writes"); |
| 455 | +fflush(stdout); |
| 456 | + |
| 457 | +gettimeofday(&start_t,NULL); |
| 458 | +for (ops=0;ops<ops_per_test;ops++) |
| 459 | +{ |
| 460 | +if (write(tmpfile,buf,WRITE_SIZE)!=WRITE_SIZE) |
| 461 | +die("write failed"); |
| 462 | +if (write(tmpfile,buf,WRITE_SIZE)!=WRITE_SIZE) |
| 463 | +die("write failed"); |
| 464 | +if (lseek(tmpfile,0,SEEK_SET)==-1) |
| 465 | +die("seek failed"); |
| 466 | +} |
| 467 | +gettimeofday(&stop_t,NULL); |
| 468 | +close(tmpfile); |
| 469 | +print_elapse(start_t,stop_t); |
463 | 470 | }
|
464 |
| -gettimeofday(&stop_t,NULL); |
465 |
| -close(tmpfile); |
466 |
| -print_elapse(start_t,stop_t); |
467 | 471 | #else
|
468 | 472 | printf(NA_FORMAT,"open_sync","n/a\n");
|
469 | 473 | #endif
|
|