#!/usr/bin/perl

use warnings;
use strict;

my $drive = shift @ARGV || '/dev/sdb';

my $mult = 0;

my $size = -1;
my $new_size = 0;

while ( $new_size > $size ) {
	$size = $new_size;

	print "# $drive $mult ", $size ? "last: $size Mb" : "", "\n";
	system "hdparm -a $mult $drive";
	my $hdparm = `hdparm -tT $drive`;
	print $hdparm;
	if ( $hdparm =~ m/buffered disk reads:\s+(\d+)\s+MB in\s+(\d+\.\d+)\s+seconds/s ) {
		$new_size = $1 / $2;
	} else {
		warn "can't find buffered disk reads:";
	}

	$mult += 16;
}


