mirror of
https://github.com/vgough/encfs.git
synced 2024-11-21 23:43:26 +01:00
tests: Add benchmark-reverse.pl
Benchmarks "encfs --reverse" rsync performance. Run "make benchmark-reverse" to run it with default settings.
This commit is contained in:
parent
c58d311569
commit
31568b1de5
@ -26,3 +26,8 @@ test-verbose:
|
||||
.PHONY: benchmark
|
||||
benchmark:
|
||||
sudo tests/benchmark.pl /var/tmp
|
||||
|
||||
.PHONY: benchmark-reverse
|
||||
benchmark-reverse:
|
||||
tests/benchmark-reverse.pl /var/tmp
|
||||
tests/benchmark-reverse.pl /var/tmp --nocache
|
||||
|
72
tests/benchmark-reverse.pl
Executable file
72
tests/benchmark-reverse.pl
Executable file
@ -0,0 +1,72 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
# Benchmark EncFS reverse mode
|
||||
|
||||
use File::Temp;
|
||||
use warnings;
|
||||
|
||||
require("tests/common.pl");
|
||||
|
||||
sub mount_encfs_reverse {
|
||||
my $p = shift;
|
||||
my $c = shift;
|
||||
my $opts = shift;
|
||||
|
||||
my $cmdline = "./encfs/encfs --extpass=\"echo test\" --standard $p $c --reverse $opts 2>&1 > /dev/null";
|
||||
# print "mounting encfs: $cmdline\n";
|
||||
my $status = system($cmdline);
|
||||
if ( $status != 0 ) { die("command returned error: $status"); }
|
||||
waitForFile("$p/.encfs6.xml") or die("Control file not created");
|
||||
|
||||
# print "encfs --reverse mounted on $c\n";
|
||||
}
|
||||
|
||||
sub cleanup {
|
||||
print "cleaning up... ";
|
||||
my $workingDir = shift;
|
||||
for(my $i=0; $i<2; $i++) {
|
||||
system("fusermount -u $workingDir/c") == 0 and last;
|
||||
system("lsof $workingDir/c");
|
||||
printf "retrying... ";
|
||||
sleep(1);
|
||||
}
|
||||
system("rm -Rf $workingDir 2> /dev/null");
|
||||
print "done\n";
|
||||
}
|
||||
|
||||
sub main {
|
||||
|
||||
my $prefix = shift(@ARGV) or die("Missing DIR argument");
|
||||
my $workingDir = mkdtemp("$prefix/encfs-performance-XXXX")
|
||||
|| die("Could not create temporary directory");
|
||||
|
||||
my $c = "$workingDir/c";
|
||||
my $p = "$workingDir/p";
|
||||
|
||||
my $opts = "";
|
||||
if ( @ARGV > 0 ) {
|
||||
$opts = shift(@ARGV)
|
||||
};
|
||||
|
||||
mkdir($c);
|
||||
mkdir($p);
|
||||
|
||||
dl_linuxgz();
|
||||
our $linuxgz;
|
||||
system("tar xzf $linuxgz -C $p");
|
||||
|
||||
mount_encfs_reverse($p, $c, $opts);
|
||||
|
||||
my @results = ();
|
||||
stopwatch_start("rsync 1 (initial copy)");
|
||||
system("rsync -a $c/ $workingDir/rsync-target");
|
||||
stopwatch_stop(\@results);
|
||||
|
||||
stopwatch_start("rsync 2 (no changes)");
|
||||
system("rsync -a $c/ $workingDir/rsync-target");
|
||||
stopwatch_stop(\@results);
|
||||
|
||||
cleanup($workingDir);
|
||||
}
|
||||
|
||||
main();
|
@ -2,21 +2,11 @@
|
||||
|
||||
# Benchmark EncFS against eCryptfs
|
||||
|
||||
use Time::HiRes qw( time );
|
||||
use File::Temp;
|
||||
use warnings;
|
||||
use feature 'state';
|
||||
|
||||
require("tests/common.pl");
|
||||
|
||||
# Download linux-3.0.tar.gz unless it already exists ("-c" flag)
|
||||
sub dl {
|
||||
our $linuxgz = "/var/tmp/linux-3.0.tar.gz";
|
||||
print "# downloading linux-3.0.tar.gz (92MiB)... ";
|
||||
system("wget -nv -c https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.0.tar.gz -O $linuxgz");
|
||||
print "done\n";
|
||||
}
|
||||
|
||||
# Create a new empty working directory
|
||||
sub newWorkingDir {
|
||||
my $prefix = shift;
|
||||
@ -76,42 +66,6 @@ sub mount_ecryptfs {
|
||||
return $p;
|
||||
}
|
||||
|
||||
# Returns integer $milliseconds from float $seconds
|
||||
sub ms {
|
||||
my $seconds = shift;
|
||||
my $milliseconds = int( $seconds * 1000 );
|
||||
return $milliseconds;
|
||||
}
|
||||
|
||||
# stopwatch_start($name)
|
||||
# start the stopwatch for test "$name"
|
||||
sub stopwatch_start {
|
||||
stopwatch(1, shift);
|
||||
}
|
||||
|
||||
# stopwatch_stop(\@results)
|
||||
# stop the stopwatch, save time into @results
|
||||
sub stopwatch_stop {
|
||||
stopwatch(0, shift);
|
||||
}
|
||||
|
||||
sub stopwatch {
|
||||
state $start_time;
|
||||
state $name;
|
||||
my $start = shift;
|
||||
|
||||
if($start) {
|
||||
$name = shift;
|
||||
print("# $name... ");
|
||||
$start_time = time();
|
||||
} else {
|
||||
my $delta = ms(time() - $start_time);
|
||||
print("$delta ms\n");
|
||||
my $results = shift;
|
||||
push( $results, [ $name, $delta, 'ms' ] );
|
||||
}
|
||||
}
|
||||
|
||||
sub benchmark {
|
||||
my $dir = shift;
|
||||
our $linuxgz;
|
||||
@ -205,7 +159,7 @@ sub main {
|
||||
exit(2);
|
||||
}
|
||||
|
||||
dl();
|
||||
dl_linuxgz();
|
||||
my $workingDir;
|
||||
my $mountpoint;
|
||||
my $prefix;
|
||||
|
@ -106,5 +106,53 @@ sub writeZeroes
|
||||
}
|
||||
}
|
||||
|
||||
# Returns integer $milliseconds from float $seconds
|
||||
sub ms {
|
||||
my $seconds = shift;
|
||||
my $milliseconds = int( $seconds * 1000 );
|
||||
return $milliseconds;
|
||||
}
|
||||
|
||||
# stopwatch_start($name)
|
||||
# start the stopwatch for test "$name"
|
||||
sub stopwatch_start {
|
||||
stopwatch(1, shift);
|
||||
}
|
||||
|
||||
# stopwatch_stop(\@results)
|
||||
# stop the stopwatch, save time into @results
|
||||
sub stopwatch_stop {
|
||||
stopwatch(0, shift);
|
||||
}
|
||||
|
||||
# See stopwatch_{start,stop} above
|
||||
use feature 'state';
|
||||
use Time::HiRes qw( time );
|
||||
sub stopwatch {
|
||||
state $start_time;
|
||||
state $name;
|
||||
my $start = shift;
|
||||
|
||||
if($start) {
|
||||
$name = shift;
|
||||
print("* $name... ");
|
||||
$start_time = time();
|
||||
} else {
|
||||
my $delta = ms(time() - $start_time);
|
||||
print("$delta ms\n");
|
||||
my $results = shift;
|
||||
push( $results, [ $name, $delta, 'ms' ] );
|
||||
}
|
||||
}
|
||||
|
||||
# Download linux-3.0.tar.gz unless it already exists ("-c" flag)
|
||||
sub dl_linuxgz {
|
||||
our $linuxgz = "/var/tmp/linux-3.0.tar.gz";
|
||||
if ( -e $linuxgz ) { return; }
|
||||
print "downloading linux-3.0.tar.gz (92MiB)... ";
|
||||
system("wget -nv -c https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.0.tar.gz -O $linuxgz");
|
||||
print "done\n";
|
||||
}
|
||||
|
||||
# As this file will be require()'d, it needs to return true
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user