From 71bfa1f0fb540790f87faac600e4041052b4d217 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 29 Nov 2015 14:50:02 +0100 Subject: tests: add scrypt benchmark Times the impact of the parameter "N" to scrypt. Results on a 2.7GHz Pentium G630: gocryptfs/cryptfs$ go test -bench=. PASS BenchmarkScrypt10-2 300 6021435 ns/op ... 6ms BenchmarkScrypt11-2 100 11861460 ns/op BenchmarkScrypt12-2 100 23420822 ns/op BenchmarkScrypt13-2 30 47666518 ns/op BenchmarkScrypt14-2 20 92561590 ns/op ... 92ms BenchmarkScrypt15-2 10 183971593 ns/op BenchmarkScrypt16-2 3 368506365 ns/op BenchmarkScrypt17-2 2 755502608 ns/op ... 755ms ok github.com/rfjakob/gocryptfs/cryptfs 18.772s --- cryptfs/kdf_test.go | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 cryptfs/kdf_test.go (limited to 'cryptfs/kdf_test.go') diff --git a/cryptfs/kdf_test.go b/cryptfs/kdf_test.go new file mode 100644 index 0000000..4d909ea --- /dev/null +++ b/cryptfs/kdf_test.go @@ -0,0 +1,60 @@ +package cryptfs + +import ( + "testing" +) + +/* +Results on a 2.7GHz Pentium G630: + +gocryptfs/cryptfs$ go test -bench=. +PASS +BenchmarkScrypt10-2 300 6021435 ns/op ... 6ms +BenchmarkScrypt11-2 100 11861460 ns/op +BenchmarkScrypt12-2 100 23420822 ns/op +BenchmarkScrypt13-2 30 47666518 ns/op +BenchmarkScrypt14-2 20 92561590 ns/op ... 92ms +BenchmarkScrypt15-2 10 183971593 ns/op +BenchmarkScrypt16-2 3 368506365 ns/op +BenchmarkScrypt17-2 2 755502608 ns/op ... 755ms +ok github.com/rfjakob/gocryptfs/cryptfs 18.772s +*/ + +func benchmarkScryptN(n int, b *testing.B) { + kdf := NewScryptKdf(n) + for i := 0; i < b.N; i++ { + kdf.DeriveKey("test") + } +} + +func BenchmarkScrypt10(b *testing.B) { + benchmarkScryptN(10, b) +} + +func BenchmarkScrypt11(b *testing.B) { + benchmarkScryptN(11, b) +} + +func BenchmarkScrypt12(b *testing.B) { + benchmarkScryptN(12, b) +} + +func BenchmarkScrypt13(b *testing.B) { + benchmarkScryptN(13, b) +} + +func BenchmarkScrypt14(b *testing.B) { + benchmarkScryptN(14, b) +} + +func BenchmarkScrypt15(b *testing.B) { + benchmarkScryptN(15, b) +} + +func BenchmarkScrypt16(b *testing.B) { + benchmarkScryptN(16, b) +} + +func BenchmarkScrypt17(b *testing.B) { + benchmarkScryptN(17, b) +} -- cgit v1.2.3