You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by va...@apache.org on 2022/12/07 01:13:29 UTC
[tinkerpop] branch 3.5-dev updated: Use a buffer to boost read/write speed
This is an automated email from the ASF dual-hosted git repository.
valentyn pushed a commit to branch 3.5-dev
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/3.5-dev by this push:
new 856703e0cf Use a buffer to boost read/write speed
new 4aa5eb2a32 Merge pull request #1884 from ministat/hj_improve_generateTempFileFromResource
856703e0cf is described below
commit 856703e0cfc1428dbf26ffcd900e8ef57ec90951
Author: Hongjiang Zhang <ho...@ebay.com>
AuthorDate: Sat Dec 3 19:13:25 2022 +0800
Use a buffer to boost read/write speed
This gives ~50X acceleration to load all the test data specified in AbstractFileGraphProvider.java.
Before this optimization, it takes 15s to finish. After applying this patch, it takes ~216ms.
---
.../main/java/org/apache/tinkerpop/gremlin/util/TestSupport.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TestSupport.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TestSupport.java
index f6e29b3a16..c5ee0a0d5b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TestSupport.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/TestSupport.java
@@ -185,10 +185,11 @@ public class TestSupport {
// fill it with the desired contents
try (final FileOutputStream outputStream = new FileOutputStream(tempFile)) {
- int data;
+ final byte[] buf = new byte[1024]; // use a buffer to boost the read/write speed
+ int sz;
try (final InputStream inputStream = resourceClass.getResourceAsStream(resourceName)) {
- while ((data = inputStream.read()) != -1) {
- outputStream.write(data);
+ while ((sz = inputStream.read(buf)) != -1) {
+ outputStream.write(buf, 0, sz);
}
}
}