summaryrefslogtreecommitdiff
path: root/src/test/java/com/keuin/kbackupfabric/backup/incremental
diff options
context:
space:
mode:
authorKeuin <[email protected]>2021-01-22 18:59:47 +0800
committerkeuin <[email protected]>2021-01-22 18:59:47 +0800
commit1c23fc14be8a0ac9542f1412448c4d896756ba01 (patch)
tree98a89f19f84877d24a99f9a256408e46b4c32f29 /src/test/java/com/keuin/kbackupfabric/backup/incremental
parent2f1d2ec7ddaebbbd19cde6314afa873f6fb964f4 (diff)
Speed up the incremental backup by using multiple CPU cores if available (use multiple threads to calculate the hash).
Diffstat (limited to 'src/test/java/com/keuin/kbackupfabric/backup/incremental')
-rw-r--r--src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java23
-rw-r--r--src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java24
2 files changed, 43 insertions, 4 deletions
diff --git a/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java b/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java
index 9a2a73c..16fb258 100644
--- a/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java
+++ b/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionFactoryTest.java
@@ -25,10 +25,29 @@ public class ObjectCollectionFactoryTest {
}
@Test
- public void fromDirectory() {
+ public void fromDirectory1() {
+ fromDirectory(1);
+ }
+
+ @Test
+ public void fromDirectory2() {
+ fromDirectory(2);
+ }
+
+ @Test
+ public void fromDirectory4() {
+ fromDirectory(4);
+ }
+
+ @Test
+ public void fromDirectory8() {
+ fromDirectory(8);
+ }
+
+ public void fromDirectory(int threads) {
try {
ObjectCollectionFactory<Sha256Identifier> factory =
- new ObjectCollectionFactory<>(Sha256Identifier.getFactory());
+ new ObjectCollectionFactory<>(Sha256Identifier.getFactory(), threads);
ObjectCollection collection =
factory.fromDirectory(new File("./testfile/ObjectCollectionFactoryTest"));
diff --git a/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java b/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java
index bd25215..33f5a9c 100644
--- a/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java
+++ b/src/test/java/com/keuin/kbackupfabric/backup/incremental/ObjectCollectionSerializerTest.java
@@ -10,10 +10,30 @@ import java.nio.file.Files;
import static org.junit.Assert.assertEquals;
public class ObjectCollectionSerializerTest {
+
+ @Test
+ public void testSerializationConsistency1() throws IOException {
+ testSerializationConsistency(1);
+ }
+
+ @Test
+ public void testSerializationConsistency2() throws IOException {
+ testSerializationConsistency(2);
+ }
+
+ @Test
+ public void testSerializationConsistency4() throws IOException {
+ testSerializationConsistency(4);
+ }
+
@Test
- public void testSerializationConsistency() throws IOException {
+ public void testSerializationConsistency8() throws IOException {
+ testSerializationConsistency(8);
+ }
+
+ public void testSerializationConsistency(int threads) throws IOException {
ObjectCollectionFactory<Sha256Identifier> factory =
- new ObjectCollectionFactory<>(Sha256Identifier.getFactory());
+ new ObjectCollectionFactory<>(Sha256Identifier.getFactory(), threads);
ObjectCollection collection =
factory.fromDirectory(new File("./testfile/ObjectCollectionFactoryTest"));
File file = new File("./testfile/serialized");