# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1352233245 -3600 # Node ID 944224048b5a6ab6682b4e11f2c7b8555c465963 # Parent 6fae698601293f3b7adc1dcddcdd8cf7dae0cdc9 Ok, seems to work so far. diff -r 6fae69860129 -r 944224048b5a .hgignore --- a/.hgignore Sun Nov 04 20:38:55 2012 +0100 +++ b/.hgignore Tue Nov 06 21:20:45 2012 +0100 @@ -0,0 +1,2 @@ +syntax:glob +log-*.log diff -r 6fae69860129 -r 944224048b5a pdd --- a/pdd Sun Nov 04 20:38:55 2012 +0100 +++ b/pdd Tue Nov 06 21:20:45 2012 +0100 @@ -1,79 +1,101 @@ #!/usr/bin/perl +# Copyright (C) 2012 Heiko Schlittermann +# These scripts are free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any +# later version. + use 5.010; use strict; use warnings; use threads; use Getopt::Long; +use Pod::Usage; sub dd; sub timer; sub main; sub kbd; +sub bg; -our $o_interval = 10; +my $o_interval = 10; +my $o_size_from = undef; +my $o_watch = undef; +my $cmd = "dd"; MAIN: { $| = 1; - my $dd; + my $worker; - GetOptions("i|interval=i" => \$o_interval) - or die "Usage: $0 [-i|--interval n]
\n"; + GetOptions( + "i|interval=i" => \$o_interval, + "h|help" => sub { pod2usage(-exit => 0, -verbose => 1) }, + "m|man" => sub { + pod2usage( + -exit => 0, + -verbose => 2, + -noperldoc => system("perldoc -V 1>/dev/null 2>&1") + ); + } + ) or pod2usage; $SIG{INT} = sub { - if (defined $dd) { - warn "Got $_[0], going to kill dd(pid:$dd)\n"; - kill $_[0] => $dd; + if (defined $worker) { + warn "Got $_[0], going to kill worker(pid:$worker)\n"; + kill $_[0] => $worker; } }; - say "[dd @ARGV]"; - - my ($if) = map /^if=(.*)/ => @ARGV; - my $ifsize = -s (defined $if ? $if : \*STDIN); + say "[$cmd @ARGV]"; - $dd = dd @ARGV; - - # the timer runs in its own thread, there it will - # send a USR1 every now and then to the $dd process + my ($if) = map { /^if=(.*)/ } @ARGV; + my $ifsize = -s (defined $if ? $if : \*STDIN); + $worker = dd @ARGV; - threads->create(\&timer, $dd); -# threads->create(\&kbd, $dd); + # we use an own thread for the timer + # (alarm/SIGALRM would suffice too… but we need + # some practice using threads) + threads->create(\&timer, $o_interval, $worker); + threads->create(\&kbd, $worker); - printf "%8s %8s %8s %15s %3s\n", - "time", "MB", "M/s", "speed", "done"; + printf "%8s %8s %8s %15s %3s\n", "elapsed", "MB", "M/s", "speed", "done"; - my ($speed, $time, $size) = (0, 0, 0); - my @output = (); + my ($speed, $elapsed, $size) = (0, 0, 0); + my @output = (); # collect temporarly the output + while (
) { - push @output, $_; + push @output, $_; /^(?\d+) \s+bytes.*copied,\s+ - (?
+ +=head1 DESCRIPTION + +B is a simple wrapper around B
to create a tabular log +suitable as input for B + +=head1 OPTIONS + +=over + +=item B<-i>|B<--interval> I + +The tick interval for measurement, unit is seconds. (default: 10) + +=item B<-h>|B<--help> + +This help/man page. + +=back + +=head1 AUTHOR + +Heiko Schlittermann + +=cut + diff -r 6fae69860129 -r 944224048b5a plot-bs.example --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot-bs.example Tue Nov 06 21:20:45 2012 +0100 @@ -0,0 +1,21 @@ +#! /usr/bin/gnuplot +set terminal qt noraise +set grid +set xlabel 'size (MB)' +set ylabel 'speed (MB/s)' +set logscale y +set title 'dd oflag=direct if=/dev/zero of=/dev/sdb' +plot 'log-dd-512M-bs=1k.log' using 2:3 title 'bs=1k' with points , \ + 'log-dd-512M-bs=2k.log' using 2:3 title 'bs=2k' with points , \ + 'log-dd-512M-bs=4k.log' using 2:3 title 'bs=4k' with points , \ + 'log-dd-512M-bs=8k.log' using 2:3 title 'bs=8k' with points , \ + 'log-dd-512M-bs=16k.log' using 2:3 title 'bs=16k' with points , \ + 'log-dd-512M-bs=32k.log' using 2:3 title 'bs=32k' with points , \ + 'log-dd-512M-bs=64k.log' using 2:3 title 'bs=64k' with points , \ + 'log-dd-512M-bs=128k.log' using 2:3 title 'bs=128k' with points , \ + 'log-dd-512M-bs=256k.log' using 2:3 title 'bs=256k' with points + +# interactive +pause -1 +# continous +#while (1) { pause 3; replot; } diff -r 6fae69860129 -r 944224048b5a plot.example --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot.example Tue Nov 06 21:20:45 2012 +0100 @@ -0,0 +1,24 @@ +#! /usr/bin/gnuplot + +# example script for gnuplot. +# I'm sure, it could be more sophisticated… + +set terminal qt noraise +set grid +set xlabel 'time (s)' +set ylabel 'speed (MB/s)' +set logscale y +set title 'dd if=bigFile …' +plot 'log-big-dd-async.log' using 1:3 title 'dd of=/dev/sdb' with lines, \ + 'log-big-dd-sync.log' using 1:3 title 'dd of=/dev/sdb oflag=sync' with lines, \ + 'log-big-vfat-default.log' using 1:3 title 'dd of=' with lines, \ + 'log-big-ext2-default.log' using 1:3 title 'dd of=' with lines, \ + 'log-big-ext4-default.log' using 1:3 title 'dd of=' with lines, \ + 'log-big-btrfs-default.log' using 1:3 title 'dd of=' with lines + + +# interaktiv +pause -1 + +# Verlauf anzeigen +#while (1) { pause 3; replot; }