#!/usr/bin/perl # # Program to test the creation and removal of a shitload of tiny files # # This line should be the only thing you need to change. The # directory needs to be created before the program starts. $dir = "."; @test_sizes = (100, 1000, 10000, 50000); $file_size = 222; $buffer = 'Q' x $file_size; chdir($dir) || die "Can't cd to $dir: $!\n"; foreach $nfiles (@test_sizes) { foreach $pass (1, 2, 3) { $stime = time; for ($i = 0; $i < $nfiles; $i++) { open(OUT, ">$i") || die "Can't open file $i: $!\n"; print OUT $buffer; close(OUT); } $etime = time; $clen = $etime - $stime; $clen = 1 if ($clen == 0); # hack to prevent divide by zero on NVSIMM run $crate = sprintf("%.2f", $nfiles / $clen); $clen = &secs2time($clen); $stime = time; for ($i = 0; $i < $nfiles; $i++) { unlink("$i") || die "Can't unlink file $i: $!\n"; } $etime = time; $rlen = $etime - $stime; $rlen = 1 if ($rlen == 0); # hack to prevent divide by zero on NVSIMM run $rrate = sprintf("%.2f", $nfiles / $rlen); $rlen = &secs2time($rlen); write; } } sub secs2time { $secs = shift; $h = int($secs/3600); $secs -= ($h*3600); $m = int($secs/60); $secs -= ($m*60); $s = $secs; return sprintf("%02d:%02d:%02d\n", $h, $m, $s); } format STDOUT_TOP = No. of Pass Create Files/ Remove Files/ Files Number Time Second Time Second ---------------------------------------------------- . format STDOUT = @>>>> @>> @<<<<<<< @>>>>>> @<<<<<<< @>>>>>> $nfiles,$pass, $clen, $crate, $rlen, $rrate . exit 0;