-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace normal file usage with memory-mapped file (#116)
* Replace normal file usage with memory-mapped file Signed-off-by: André Silva <[email protected]> * Refactor load method Signed-off-by: André Silva <[email protected]>
- Loading branch information
1 parent
2d6d94d
commit ee045f4
Showing
20 changed files
with
130 additions
and
236 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
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
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 |
---|---|---|
@@ -1,12 +1,10 @@ | ||
package eu.stamp_project.testrunner.listener.impl; | ||
|
||
import eu.stamp_project.testrunner.listener.Coverage; | ||
import eu.stamp_project.testrunner.listener.utils.ListenerUtils; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.ObjectOutputStream; | ||
import java.io.Serializable; | ||
import eu.stamp_project.testrunner.listener.Coverage; | ||
import eu.stamp_project.testrunner.listener.TestResult; | ||
import eu.stamp_project.testrunner.runner.Loader; | ||
|
||
/** | ||
* created by Benjamin DANGLOT [email protected] on 14/11/18 | ||
|
@@ -54,33 +52,16 @@ public String toString() { | |
|
||
@Override | ||
public void save() { | ||
File outputDir = new File(TestResult.OUTPUT_DIR); | ||
if (!outputDir.exists()) { | ||
if (!outputDir.mkdirs()) { | ||
System.err.println("Error while creating output dir"); | ||
} | ||
} | ||
File f = new File(outputDir, SERIALIZE_NAME + EXTENSION); | ||
try (FileOutputStream fout = new FileOutputStream(f)) { | ||
try (ObjectOutputStream oos = new ObjectOutputStream(fout)) { | ||
oos.writeObject(this); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} catch (Exception e) { | ||
System.err.println("Error while writing serialized file."); | ||
throw new RuntimeException(e); | ||
} | ||
System.out.println("File saved to the following path: " + f.getAbsolutePath()); | ||
ListenerUtils.saveToMemoryMappedFile(new File(OUTPUT_DIR, SHARED_MEMORY_FILE), this); | ||
} | ||
|
||
/** | ||
* Load from serialized object | ||
* Loads and deserializes the file from a memory mapped file | ||
* | ||
* @return an Instance of JUnit4Coverage loaded from a serialized file. | ||
* @return loaded CoverageDetailed from the memory mapped file | ||
*/ | ||
public static Coverage load() { | ||
return new Loader<Coverage>().load(SERIALIZE_NAME); | ||
return ListenerUtils.loadFromMemoryMappedFile(ListenerUtils.computeTargetFilePath(OUTPUT_DIR, SHARED_MEMORY_FILE)); | ||
} | ||
|
||
@Override | ||
|
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
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
Oops, something went wrong.