generated from prairir/project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmarking to encrypt, decrypt, and walk
Add file generation with sizes of 2mb, 4mb, 8mb, 16mb, 32mb, 64mb, 128mb, 256mb, 512mb, 1024mb, 2048mb. These files are created using dd from /dev/random. The files get copied into a container and then benchmarking is ran on the encryptfile.EncryptFile.Do, decryptfile.DecryptFile.Do, and walk.Walk for both encrypt and decrypt. It uses these files for benchmarking.
- Loading branch information
Showing
5 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package decryptfile_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/prairir/imacry/pkg/config" | ||
"github.com/prairir/imacry/pkg/decryptfile" | ||
) | ||
|
||
var dec = decryptfile.DecryptFile{} | ||
|
||
func BenchmarkDecryptFile(b *testing.B) { | ||
config.Config.Password = "123456789012345678901234" | ||
tests := []struct { | ||
name string | ||
filePath string | ||
}{ | ||
{"2MB", "/root/file00"}, | ||
{"4MB", "/root/file01"}, | ||
{"8MB", "/root/file02"}, | ||
{"16MB", "/root/file03"}, | ||
{"32MB", "/root/file04"}, | ||
{"64MB", "/root/file05"}, | ||
{"128MB", "/root/file06"}, | ||
{"256MB", "/root/file07"}, | ||
{"512MB", "/root/file08"}, | ||
{"1024MB", "/root/file09"}, | ||
{"2056MB", "/root/file10"}, | ||
} | ||
for _, test := range tests { | ||
b.Run(test.name, func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
dec.Do(test.filePath) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package encryptfile_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/prairir/imacry/pkg/config" | ||
"github.com/prairir/imacry/pkg/encryptfile" | ||
) | ||
|
||
var enc = encryptfile.EncryptFile{} | ||
|
||
func BenchmarkEncryptFile(b *testing.B) { | ||
config.Config.Password = "123456789012345678901234" | ||
tests := []struct { | ||
name string | ||
filePath string | ||
}{ | ||
{"2MB", "/root/file00"}, | ||
{"4MB", "/root/file01"}, | ||
{"8MB", "/root/file02"}, | ||
{"16MB", "/root/file03"}, | ||
{"32MB", "/root/file04"}, | ||
{"64MB", "/root/file05"}, | ||
{"128MB", "/root/file06"}, | ||
{"256MB", "/root/file07"}, | ||
{"512MB", "/root/file08"}, | ||
{"1024MB", "/root/file09"}, | ||
{"2056MB", "/root/file10"}, | ||
} | ||
for _, test := range tests { | ||
b.Run(test.name, func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
enc.Do(test.filePath) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package walk_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/prairir/imacry/pkg/config" | ||
"github.com/prairir/imacry/pkg/decryptfile" | ||
"github.com/prairir/imacry/pkg/encryptfile" | ||
"github.com/prairir/imacry/pkg/walk" | ||
) | ||
|
||
func BenchmarkWalk(b *testing.B) { | ||
config.Config.Password = "123456789012345678901234" | ||
|
||
tests := []struct { | ||
name string | ||
fun walk.FileAction | ||
}{ | ||
{"encrypt", encryptfile.EncryptFile{}}, | ||
{"decrypt", decryptfile.DecryptFile{}}, | ||
} | ||
for _, test := range tests { | ||
b.Run(test.name, func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
walk.Walk("/root/", test.fun) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/bin/bash | ||
|
||
set -euxo | ||
|
||
# benchmarking script | ||
# creates a large number of files | ||
|
||
# filename is of | ||
# file size is (bs * count) | ||
|
||
dd if=/dev/random of=~/file00 bs=1M count=2 | ||
|
||
dd if=/dev/random of=~/file01 bs=1M count=4 | ||
|
||
dd if=/dev/random of=~/file02 bs=1M count=8 | ||
|
||
dd if=/dev/random of=~/file03 bs=1M count=16 | ||
|
||
dd if=/dev/random of=~/file04 bs=1M count=32 | ||
|
||
dd if=/dev/random of=~/file05 bs=1M count=64 | ||
|
||
dd if=/dev/random of=~/file06 bs=1M count=128 | ||
|
||
dd if=/dev/random of=~/file07 bs=1M count=256 | ||
|
||
dd if=/dev/random of=~/file08 bs=1M count=512 | ||
|
||
dd if=/dev/random of=~/file09 bs=1M count=1024 | ||
|
||
dd if=/dev/random of=~/file10 bs=1M count=2048 |