mirror of
https://github.com/vgough/encfs.git
synced 2024-12-28 01:29:18 +01:00
Merge pull request #45 from rfjakob/next
Add PATH_MAX workaround, improve benchmark.pl
This commit is contained in:
commit
6df09679c6
@ -22,3 +22,7 @@ test:
|
|||||||
.PHONY: test-verbose
|
.PHONY: test-verbose
|
||||||
test-verbose:
|
test-verbose:
|
||||||
perl -MTest::Harness -e '$$Test::Harness::verbose=1; runtests @ARGV;' tests/*.t.pl
|
perl -MTest::Harness -e '$$Test::Harness::verbose=1; runtests @ARGV;' tests/*.t.pl
|
||||||
|
|
||||||
|
.PHONY: benchmark
|
||||||
|
benchmark:
|
||||||
|
sudo tests/benchmark.pl /var/tmp
|
||||||
|
@ -44,6 +44,10 @@
|
|||||||
#include "i18n.h"
|
#include "i18n.h"
|
||||||
#include "shared_ptr.h"
|
#include "shared_ptr.h"
|
||||||
|
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
#define PATH_MAX 4096
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace rlog;
|
using namespace rlog;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using gnu::autosprintf;
|
using gnu::autosprintf;
|
||||||
|
@ -5,13 +5,14 @@
|
|||||||
use Time::HiRes qw( time );
|
use Time::HiRes qw( time );
|
||||||
use File::Temp;
|
use File::Temp;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use feature 'state';
|
||||||
|
|
||||||
require("tests/common.pl");
|
require("tests/common.pl");
|
||||||
|
|
||||||
# Download linux-3.0.tar.gz unless it already exists ("-c" flag)
|
# Download linux-3.0.tar.gz unless it already exists ("-c" flag)
|
||||||
sub dl {
|
sub dl {
|
||||||
our $linuxgz = "/tmp/linux-3.0.tar.gz";
|
our $linuxgz = "/var/tmp/linux-3.0.tar.gz";
|
||||||
print "# downloading 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");
|
system("wget -nv -c https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.0.tar.gz -O $linuxgz");
|
||||||
print "done\n";
|
print "done\n";
|
||||||
}
|
}
|
||||||
@ -53,6 +54,12 @@ sub mount_encfs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub mount_ecryptfs {
|
sub mount_ecryptfs {
|
||||||
|
|
||||||
|
if(system("which mount.ecryptfs > /dev/null") != 0) {
|
||||||
|
print "skipping ecryptfs\n";
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
my $workingDir = shift;
|
my $workingDir = shift;
|
||||||
|
|
||||||
my $c = "$workingDir/ecryptfs_ciphertext";
|
my $c = "$workingDir/ecryptfs_ciphertext";
|
||||||
@ -76,54 +83,70 @@ sub ms {
|
|||||||
return $milliseconds;
|
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 {
|
sub benchmark {
|
||||||
my $dir = shift;
|
my $dir = shift;
|
||||||
my $start;
|
|
||||||
our $linuxgz;
|
our $linuxgz;
|
||||||
my $delta;
|
|
||||||
my $line;
|
|
||||||
|
|
||||||
my @results = ();
|
my @results = ();
|
||||||
|
|
||||||
system("sync");
|
system("sync");
|
||||||
print("# stream_write... ");
|
stopwatch_start("stream_write");
|
||||||
$start = time();
|
writeZeroes( "$dir/zero", 1024 * 1024 * 100 );
|
||||||
writeZeroes( "$dir/zero", 1024 * 1024 * 100 );
|
system("sync");
|
||||||
system("sync");
|
stopwatch_stop(\@results);
|
||||||
$delta = time() - $start;
|
|
||||||
push( @results, [ 'stream_write', int( 100 / $delta ), "MiB/s" ] );
|
|
||||||
printf("done\n");
|
|
||||||
unlink("$dir/zero");
|
unlink("$dir/zero");
|
||||||
|
|
||||||
system("sync");
|
system("sync");
|
||||||
system("cat $linuxgz > /dev/null");
|
system("cat $linuxgz > /dev/null");
|
||||||
print("# extract... ");
|
stopwatch_start("extract");
|
||||||
$start = time();
|
system("tar xzf $linuxgz -C $dir");
|
||||||
system("tar xzf $linuxgz -C $dir");
|
system("sync");
|
||||||
system("sync");
|
stopwatch_stop(\@results);
|
||||||
$delta = ms( time() - $start );
|
|
||||||
push( @results, [ 'extract', $delta, "ms" ] );
|
|
||||||
print("done\n");
|
|
||||||
|
|
||||||
$du = qx(du -sm $dir | cut -f1);
|
$du = qx(du -sm $dir | cut -f1);
|
||||||
push( @results, [ 'du', $du, 'MB' ] );
|
push( @results, [ 'du', $du, 'MiB' ] );
|
||||||
printf( "# disk space used: %d MB\n", $du );
|
printf( "# disk space used: %d MiB\n", $du );
|
||||||
|
|
||||||
system("echo 3 > /proc/sys/vm/drop_caches");
|
system("echo 3 > /proc/sys/vm/drop_caches");
|
||||||
$start = time();
|
stopwatch_start("rsync");
|
||||||
system("rsync -an $dir /tmp");
|
system("rsync -an $dir $dir/empty-rsync-target");
|
||||||
$delta = time() - $start;
|
stopwatch_stop(\@results);
|
||||||
push( @results, [ 'rsync', ms($delta), 'ms' ] );
|
|
||||||
printf( "# rsync took %d ms\n", ms($delta) );
|
|
||||||
|
|
||||||
system("echo 3 > /proc/sys/vm/drop_caches");
|
system("echo 3 > /proc/sys/vm/drop_caches");
|
||||||
system("sync");
|
system("sync");
|
||||||
$start = time();
|
stopwatch_start("rm");
|
||||||
system("rm -Rf $dir/*");
|
system("rm -Rf $dir/*");
|
||||||
system("sync");
|
system("sync");
|
||||||
$delta = time() - $start;
|
stopwatch_stop(\@results);
|
||||||
push( @results, [ 'delete', ms($delta), 'ms' ] );
|
|
||||||
printf( "# delete took %d ms\n", ms($delta) );
|
|
||||||
|
|
||||||
return \@results;
|
return \@results;
|
||||||
}
|
}
|
||||||
@ -134,7 +157,10 @@ sub tabulate {
|
|||||||
$r = shift;
|
$r = shift;
|
||||||
my @encfs = @{$r};
|
my @encfs = @{$r};
|
||||||
$r = shift;
|
$r = shift;
|
||||||
my @ecryptfs = @{$r};
|
my @ecryptfs;
|
||||||
|
if($r) {
|
||||||
|
@ecryptfs = @{$r};
|
||||||
|
}
|
||||||
|
|
||||||
print " Test | EncFS | eCryptfs | EncFS advantage\n";
|
print " Test | EncFS | eCryptfs | EncFS advantage\n";
|
||||||
print ":---------------|-------------:|-------------:|---------------:\n";
|
print ":---------------|-------------:|-------------:|---------------:\n";
|
||||||
@ -144,12 +170,17 @@ sub tabulate {
|
|||||||
my $unit = $encfs[$i][2];
|
my $unit = $encfs[$i][2];
|
||||||
|
|
||||||
my $en = $encfs[$i][1];
|
my $en = $encfs[$i][1];
|
||||||
my $ec = $ecryptfs[$i][1];
|
my $ec = 0;
|
||||||
|
my $ratio = 0;
|
||||||
|
|
||||||
my $ratio = $ec / $en;
|
if( @ecryptfs ) {
|
||||||
if ( $unit =~ m!/s! ) {
|
$ec = $ecryptfs[$i][1];
|
||||||
$ratio = $en / $ec;
|
$ratio = $ec / $en;
|
||||||
|
if ( $unit =~ m!/s! ) {
|
||||||
|
$ratio = $en / $ec;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf( "%-15s | %6d %-5s | %6d %-5s | %2.2f\n",
|
printf( "%-15s | %6d %-5s | %6d %-5s | %2.2f\n",
|
||||||
$test, $en, $unit, $ec, $unit, $ratio );
|
$test, $en, $unit, $ec, $unit, $ratio );
|
||||||
}
|
}
|
||||||
@ -157,7 +188,15 @@ sub tabulate {
|
|||||||
|
|
||||||
sub main {
|
sub main {
|
||||||
if ( $#ARGV < 0 ) {
|
if ( $#ARGV < 0 ) {
|
||||||
print "Usage: test/benchmark.pl MOUNTPOINT [MOUNTPOINT] [...]\n";
|
print "Usage: test/benchmark.pl DIR1 [DIR2] [...]\n";
|
||||||
|
print "\n";
|
||||||
|
print "Arguments:\n";
|
||||||
|
print " DIRn ... Working directory. This is where the encrypted files\n";
|
||||||
|
print " are stored. Specifying multiple directories will run\n";
|
||||||
|
print " the benchmark in each.\n";
|
||||||
|
print "\n";
|
||||||
|
print "For details about the testcases see PERFORMANCE.md.\n";
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +219,10 @@ sub main {
|
|||||||
|
|
||||||
print "# mounting ecryptfs\n";
|
print "# mounting ecryptfs\n";
|
||||||
$mountpoint = mount_ecryptfs($workingDir);
|
$mountpoint = mount_ecryptfs($workingDir);
|
||||||
my $ecryptfs_results = benchmark($mountpoint);
|
my $ecryptfs_results;
|
||||||
|
if($mountpoint) {
|
||||||
|
$ecryptfs_results = benchmark($mountpoint);
|
||||||
|
}
|
||||||
|
|
||||||
cleanup($workingDir);
|
cleanup($workingDir);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user