~vadim-tk/sysbench/oltp_skip_trx

« back to all changes in this revision

Viewing changes to sysbench/tests/fileio/sb_fileio.c

  • Committer: Alexey Kopytov
  • Date: 2010-11-01 09:01:02 UTC
  • mfrom: (62.1.11 sysbench-0.4)
  • Revision ID: alexey.kopytov@oracle.com-20101101090102-fg4y1vcvex4l47b5
Manual merge from 0.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
168
168
static int write_ops;
169
169
static int real_write_ops;
170
170
static int other_ops;
 
171
static int last_other_ops;
171
172
static unsigned int req_performed; /* number of requests done */
172
173
static unsigned long long bytes_read;
173
 
static unsigned long long  bytes_written;
 
174
static unsigned long long last_bytes_read;
 
175
static unsigned long long bytes_written;
 
176
static unsigned long long last_bytes_written;
174
177
 
175
178
#ifdef HAVE_MMAP
176
179
/* Array of file mappings */
229
232
static int file_thread_done(int);
230
233
#endif
231
234
static int file_done(void);
232
 
static void file_print_stats(void);
 
235
static void file_print_stats(sb_stat_t);
233
236
 
234
237
static sb_test_t fileio_test =
235
238
{
787
790
/* Print test statistics */
788
791
 
789
792
 
790
 
void file_print_stats(void)
 
793
void file_print_stats(sb_stat_t type)
791
794
{
792
 
  double total_time;
 
795
  double seconds;
793
796
  char   s1[16], s2[16], s3[16], s4[16];
794
797
 
795
 
  total_time = NS2SEC(sb_timer_value(&sb_globals.exec_timer));
796
 
  
797
 
  log_text(LOG_NOTICE,
798
 
           "Operations performed:  %d Read, %d Write, %d Other = %d Total",
799
 
           read_ops, write_ops, other_ops, read_ops + write_ops + other_ops); 
800
 
  log_text(LOG_NOTICE, "Read %sb  Written %sb  Total transferred %sb  "
801
 
           "(%sb/sec)",
802
 
           sb_print_value_size(s1, sizeof(s1), bytes_read),
803
 
           sb_print_value_size(s2, sizeof(s2), bytes_written),
804
 
           sb_print_value_size(s3, sizeof(s3), bytes_read + bytes_written),
805
 
           sb_print_value_size(s4, sizeof(s4),
806
 
                               (bytes_read + bytes_written) / total_time));  
807
 
  log_text(LOG_NOTICE, "%8.2f Requests/sec executed",
808
 
           (read_ops + write_ops) / total_time);  
 
798
  switch (type) {
 
799
  case SB_STAT_INTERMEDIATE:
 
800
    {
 
801
      const double megabyte = 1024.0 * 1024.0;
 
802
 
 
803
      SB_THREAD_MUTEX_LOCK();
 
804
 
 
805
      seconds = NS2SEC(sb_timer_split(&sb_globals.exec_timer));
 
806
      log_timestamp(LOG_NOTICE, &sb_globals.exec_timer,
 
807
                    "reads: %4.2f MB/s writes: %4.2f MB/s fsyncs: %4.2f/s",
 
808
                    (bytes_read - last_bytes_read) / megabyte / seconds,
 
809
                    (bytes_written - last_bytes_written) / megabyte / seconds,
 
810
                    (other_ops - last_other_ops) / seconds);
 
811
      last_bytes_read = bytes_read;
 
812
      last_bytes_written = bytes_written;
 
813
      last_other_ops = other_ops;
 
814
 
 
815
      SB_THREAD_MUTEX_UNLOCK();
 
816
 
 
817
      break;
 
818
    }
 
819
 
 
820
  case SB_STAT_CUMULATIVE:
 
821
    seconds = NS2SEC(sb_timer_value(&sb_globals.exec_timer));
 
822
 
 
823
    log_text(LOG_NOTICE,
 
824
             "Operations performed:  %d reads, %d writes, %d Other = %d Total",
 
825
             read_ops, write_ops, other_ops, read_ops + write_ops + other_ops);
 
826
    log_text(LOG_NOTICE, "Read %sb  Written %sb  Total transferred %sb  "
 
827
             "(%sb/sec)",
 
828
             sb_print_value_size(s1, sizeof(s1), bytes_read),
 
829
             sb_print_value_size(s2, sizeof(s2), bytes_written),
 
830
             sb_print_value_size(s3, sizeof(s3), bytes_read + bytes_written),
 
831
             sb_print_value_size(s4, sizeof(s4),
 
832
                                 (bytes_read + bytes_written) / seconds));
 
833
    log_text(LOG_NOTICE, "%8.2f Requests/sec executed",
 
834
             (read_ops + write_ops) / seconds);
 
835
    break;
 
836
  }
809
837
}
810
838
 
811
839
 
975
1003
  write_ops = 0;
976
1004
  real_write_ops = 0;
977
1005
  other_ops = 0;
 
1006
  last_other_ops = 0;
978
1007
  bytes_read = 0;
 
1008
  last_bytes_read = 0;
979
1009
  bytes_written = 0;
 
1010
  last_bytes_written = 0;
980
1011
  req_performed = 0;
981
1012
  is_dirty = 0;
982
1013
  if (sb_globals.validate)
1899
1930
    buf[i] = sb_rnd() & 0xFF;
1900
1931
 
1901
1932
  /* Store the checksum */
1902
 
  *(int *)(buf + i) = (int)crc32(0, buf, len -
 
1933
  *(int *)(buf + i) = (int)crc32(0, (unsigned char *)buf, len -
1903
1934
                                 (FILE_CHECKSUM_LENGTH + FILE_OFFSET_LENGTH));
1904
1935
  /* Store the offset */
1905
1936
  *(long *)(buf + i + FILE_CHECKSUM_LENGTH) = offset;
1916
1947
 
1917
1948
  cs_offset = len - (FILE_CHECKSUM_LENGTH + FILE_OFFSET_LENGTH);
1918
1949
  
1919
 
  checksum = (unsigned int)crc32(0, buf, cs_offset);
 
1950
  checksum = (unsigned int)crc32(0, (unsigned char *)buf, cs_offset);
1920
1951
 
1921
1952
  if (checksum != *(unsigned int *)(buf + cs_offset))
1922
1953
  {