Skip to content
Snippets Groups Projects
Commit 848450cf authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

Buffered read/write

parent 524d2adc
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,8 @@ import cz.fidentis.analyst.mesh.events.MeshEvent; ...@@ -7,6 +7,8 @@ import cz.fidentis.analyst.mesh.events.MeshEvent;
import cz.fidentis.analyst.mesh.events.MeshListener; import cz.fidentis.analyst.mesh.events.MeshListener;
import cz.fidentis.analyst.mesh.io.MeshObjLoader; import cz.fidentis.analyst.mesh.io.MeshObjLoader;
import cz.fidentis.analyst.symmetry.Plane; import cz.fidentis.analyst.symmetry.Plane;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -154,8 +156,9 @@ public class HumanFace implements MeshListener, Serializable { ...@@ -154,8 +156,9 @@ public class HumanFace implements MeshListener, Serializable {
public File dumpToFile() throws IOException { public File dumpToFile() throws IOException {
File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".ser"); File tempFile = File.createTempFile(this.getClass().getSimpleName(), ".ser");
tempFile.deleteOnExit(); tempFile.deleteOnExit();
try (ObjectOutputStream fos = new ObjectOutputStream(new FileOutputStream(tempFile))) { try (ObjectOutputStream fos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(tempFile)))) {
fos.writeObject(this); fos.writeObject(this);
fos.flush();
} }
return tempFile; return tempFile;
} }
...@@ -169,7 +172,7 @@ public class HumanFace implements MeshListener, Serializable { ...@@ -169,7 +172,7 @@ public class HumanFace implements MeshListener, Serializable {
* @throws java.lang.ClassNotFoundException on error when instantiating the human face * @throws java.lang.ClassNotFoundException on error when instantiating the human face
*/ */
public static HumanFace restoreFromFile(File dumpFile) throws IOException, ClassNotFoundException { public static HumanFace restoreFromFile(File dumpFile) throws IOException, ClassNotFoundException {
try (ObjectInputStream fos = new ObjectInputStream(new FileInputStream(dumpFile))) { try (ObjectInputStream fos = new ObjectInputStream(new BufferedInputStream(new FileInputStream(dumpFile)))) {
return (HumanFace) fos.readObject(); return (HumanFace) fos.readObject();
} }
} }
......
...@@ -45,11 +45,13 @@ public class EfficiencyTests { ...@@ -45,11 +45,13 @@ public class EfficiencyTests {
face1.getMeshModel().simplifyModel(); face1.getMeshModel().simplifyModel();
face2.getMeshModel().simplifyModel(); face2.getMeshModel().simplifyModel();
/*
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
HumanFace face = HumanFacePrivilegedCache.instance().loadFace(faceFile4); HumanFace face = HumanFacePrivilegedCache.instance().loadFace(faceFile4);
face.getMeshModel().simplifyModel(); face.getMeshModel().simplifyModel();
System.out.println(i+".\t" + HumanFacePrivilegedCache.instance()); System.out.println(i+".\t" + HumanFacePrivilegedCache.instance());
} }
*/
boolean relativeDist = false; boolean relativeDist = false;
boolean printDetails = false; boolean printDetails = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment