diff options
author | makamys <makamys@outlook.com> | 2021-05-10 23:46:53 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-11 02:18:49 +0200 |
commit | 74b98178d425ea07bbcb5825e2868764f1cebc79 (patch) | |
tree | d830cb8159833a47e9a9da58b8e07f57c6037818 /src | |
parent | ec94ac14a74a52439c666fc494d4696c146aad95 (diff) | |
download | Neodymium-74b98178d425ea07bbcb5825e2868764f1cebc79.tar.gz Neodymium-74b98178d425ea07bbcb5825e2868764f1cebc79.tar.bz2 Neodymium-74b98178d425ea07bbcb5825e2868764f1cebc79.zip |
Do writing on thread
Reduces save time from 3.4s to 0.4s in my testing
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/makamys/lodmod/renderer/LODRegion.java | 17 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/renderer/LODRenderer.java | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/main/java/makamys/lodmod/renderer/LODRegion.java b/src/main/java/makamys/lodmod/renderer/LODRegion.java index 2fa4f01..404ec81 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRegion.java +++ b/src/main/java/makamys/lodmod/renderer/LODRegion.java @@ -102,7 +102,22 @@ public class LODRegion { } } nbt.setTag("chunks", list); - CompressedStreamTools.writeCompressed(nbt, new FileOutputStream(saveFile)); + + new Thread( + new Runnable() { + + @Override + public void run() { + try { + CompressedStreamTools.writeCompressed(nbt, new FileOutputStream(saveFile)); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } + }).start(); + } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 7578633..22a812e 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -627,8 +627,9 @@ public class LODRenderer { public void onSave() { System.out.println("Saving LOD regions..."); + long t0 = System.currentTimeMillis(); loadedRegionsMap.forEach((k, v) -> v.save(getSaveDir())); - System.out.println("Finished saving LOD regions"); + System.out.println("Finished saving LOD regions in " + ((System.currentTimeMillis() - t0) / 1000.0) + "s"); } private Path getSaveDir(){ |