Skip to content

Instantly share code, notes, and snippets.

@sh2
Created September 5, 2012 05:59
Show Gist options
  • Save sh2/3631311 to your computer and use it in GitHub Desktop.
Save sh2/3631311 to your computer and use it in GitHub Desktop.
fio test/summarize script
#!/usr/bin/perl
use strict;
use warnings;
my (%sequential, %random);
my ($type, $blocksize, $ratio, $iodepth, $header);
while (my $line = <STDIN>) {
if ($line =~ /^fio_seq_(\w+)/) {
$type = $1;
} elsif ($line =~ /^ +(read|write).*bw=([\d\.]+)(MB|KB)/) {
if ($3 eq 'MB') {
$sequential{$type} = $2;
} else {
$sequential{$type} = $2 / 1024;
}
if ($type eq 'write') {
last;
}
}
}
while (my $line = <STDIN>) {
if ($line =~ /^fio_b(\d+)k_r(\d+)_q(\d+)/) {
($blocksize, $ratio, $iodepth) = ($1, $2, $3);
$random{$blocksize}->{$iodepth}->{$ratio} = 0;
} elsif ($line =~ /^ +(read|write).*iops=(\d+)/) {
$random{$blocksize}->{$iodepth}->{$ratio} += $2;
}
}
printf "sequential read (MB/s),%.1f\n", $sequential{'read'};
printf "sequential write (MB/s),%.1f\n\n", $sequential{'write'};
print "random read/write (IOPS)\n";
foreach $blocksize (sort { $a <=> $b } keys %random) {
$header = 1;
foreach $iodepth (sort { $a <=> $b } keys %{$random{$blocksize}}) {
if ($header) {
print 'block size (KB),queue depth,';
foreach $ratio (sort { $b <=> $a } keys %{$random{$blocksize}->{$iodepth}}) {
printf "r%d:w%d,", $ratio, 100 - $ratio;
}
print "\n";
$header = 0;
}
print "$blocksize,$iodepth,";
foreach $ratio (sort { $b <=> $a } keys %{$random{$blocksize}->{$iodepth}}) {
print $random{$blocksize}->{$iodepth}->{$ratio} . ',';
}
print "\n";
}
}
#!/bin/bash
# Configuration
FILEPREFIX=/tmp/fio_test
SIZE=16g
RUNTIME=60
SLEEPTIME=10
# Benchmark
LOGFILE=fio_`date +'%Y%m%d-%H%M%S'`.log
NUMFILES=`echo $SIZE | tr -d g`
FILENAME=$FILEPREFIX.001
for FILESUFFIX in `seq 2 $NUMFILES`; do
FILENAME=$FILENAME:$FILEPREFIX.`printf "%03d" $FILESUFFIX`
done
fio -direct=1 -blocksize=1m -ioengine=libaio -iodepth=256 \
-filename=$FILENAME -size=$SIZE -runtime=$RUNTIME \
-readwrite=read -name=fio_seq_read >> $LOGFILE
sleep $SLEEPTIME
fio -direct=1 -blocksize=1m -ioengine=libaio -iodepth=256 \
-filename=$FILENAME -size=$SIZE -runtime=$RUNTIME \
-readwrite=write -name=fio_seq_write >> $LOGFILE
sleep $SLEEPTIME
# for BLOCKSIZE in 4k; do
for BLOCKSIZE in 4k 8k 16k; do
for RATIO in 100 90 50 10 0; do
for IODEPTH in 1 2 4 8 16 32 64 128 256; do
fio -direct=1 -ioengine=libaio -readwrite=randrw \
-filename=$FILENAME -size=$SIZE -runtime=$RUNTIME \
-blocksize=$BLOCKSIZE -rwmixread=$RATIO -iodepth=$IODEPTH \
-name=fio_b${BLOCKSIZE}_r${RATIO}_q${IODEPTH} >> $LOGFILE
sleep $SLEEPTIME
done
done
done
for FILESUFFIX in `seq 1 $NUMFILES`; do
rm -f $FILEPREFIX.`printf "%03d" $FILESUFFIX`
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment