You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hugegraph.apache.org by "javeme (via GitHub)" <gi...@apache.org> on 2025/08/30 15:35:29 UTC

[PR] perf(example): add PerfExample5 and PerfExample6 [incubator-hugegraph]

javeme opened a new pull request, #2860:
URL: https://github.com/apache/incubator-hugegraph/pull/2860

   Change-Id: Ibe3df29c6926c5c58bab217220f3005d92476f7b
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] perf(example): add PerfExample5 and PerfExample6 [incubator-hugegraph]

Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #2860:
URL: https://github.com/apache/incubator-hugegraph/pull/2860#issuecomment-3239358750

   ## [Codecov](https://app.codecov.io/gh/apache/incubator-hugegraph/pull/2860?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 33.82%. Comparing base ([`0946d5d`](https://app.codecov.io/gh/apache/incubator-hugegraph/commit/0946d5dd0cad8c27cb365b0c2aaaf217cdca3402?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`2733ccb`](https://app.codecov.io/gh/apache/incubator-hugegraph/commit/2733ccb019ba5ff6dcbbcb53faa0a531ea710053?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   > :exclamation:  There is a different number of reports uploaded between BASE (0946d5d) and HEAD (2733ccb). Click for more details.
   > 
   > <details><summary>HEAD has 2 uploads less than BASE</summary>
   >
   >| Flag | BASE (0946d5d) | HEAD (2733ccb) |
   >|------|------|------|
   >||3|1|
   ></details>
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #2860      +/-   ##
   ============================================
   - Coverage     40.91%   33.82%   -7.09%     
   + Complexity      333      264      -69     
   ============================================
     Files           747      747              
     Lines         60168    60168              
     Branches       7683     7683              
   ============================================
   - Hits          24615    20351    -4264     
   - Misses        32975    37523    +4548     
   + Partials       2578     2294     -284     
   ```
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/incubator-hugegraph/pull/2860?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] perf(example): add PerfExample5 and PerfExample6 [incubator-hugegraph]

Posted by "VGalaxies (via GitHub)" <gi...@apache.org>.
VGalaxies merged PR #2860:
URL: https://github.com/apache/incubator-hugegraph/pull/2860


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] perf(example): add PerfExample5 and PerfExample6 [incubator-hugegraph]

Posted by "javeme (via GitHub)" <gi...@apache.org>.
javeme commented on code in PR #2860:
URL: https://github.com/apache/incubator-hugegraph/pull/2860#discussion_r2328637371


##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample6.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.example;
+
+import org.apache.hugegraph.HugeFactory;
+import org.apache.hugegraph.util.Log;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.slf4j.Logger;
+
+/**
+ * Perf test for: query vertices/adj-edges by ids
+ */
+public class PerfExample6 extends PerfExample5 {
+
+    private static final Logger LOG = Log.logger(PerfExample6.class);
+
+    /**
+     * Main method
+     * @param args 3 arguments, 1st should be 1, meaning single thread,
+     *             product of 2nd and 3rd is total number of "person" vertices
+     * @throws InterruptedException
+     */
+    public static void main(String[] args) throws Exception {
+        PerfExample6 tester = new PerfExample6();
+        tester.test(args);
+
+        // Stop daemon thread
+        HugeFactory.shutdown(30L);
+    }
+
+    @Override
+    protected void testInsert(GraphManager graph, int times, int multiple) {
+        final int TIMES = times * multiple;

Review Comment:
   Only the insertion test involves batch, and batch is not a dimension we test, so keep it for now.



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample1.java:
##########
@@ -34,6 +36,8 @@
  */
 public class PerfExample1 extends PerfExampleBase {
 
+    private static final Logger LOG = Log.logger(PerfExample1.class);

Review Comment:
   this time we marked the PerfExampleBase.LOG as private.



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample5.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.example;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.HugeFactory;
+import org.apache.hugegraph.type.define.Directions;
+import org.apache.hugegraph.util.Log;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.slf4j.Logger;
+
+/**

Review Comment:
   PerfExample3 is a test for: insert vertices with indexes in order



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample6.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.example;
+
+import org.apache.hugegraph.HugeFactory;
+import org.apache.hugegraph.util.Log;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.slf4j.Logger;
+
+/**
+ * Perf test for: query vertices/adj-edges by ids
+ */

Review Comment:
   In this PerfExample6 test, we insert some edges (one edge per vertex) for adj-edges test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] perf(example): add PerfExample5 and PerfExample6 [incubator-hugegraph]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2860:
URL: https://github.com/apache/incubator-hugegraph/pull/2860#discussion_r2313249015


##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExampleBase.java:
##########
@@ -235,6 +240,11 @@ protected void testQueryEdge(GraphManager graph, int threads, int thread, int mu
                   totalV, thread, totalE);
     }
 
+    protected static long elapsed(long start) {

Review Comment:
   Good refactoring to move the elapsed() method to the base class where it can be reused by all performance examples.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] perf(example): add PerfExample5 and PerfExample6 [incubator-hugegraph]

Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2860:
URL: https://github.com/apache/incubator-hugegraph/pull/2860#discussion_r2313248366


##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample1.java:
##########
@@ -34,6 +36,8 @@
  */
 public class PerfExample1 extends PerfExampleBase {
 
+    private static final Logger LOG = Log.logger(PerfExample1.class);

Review Comment:
   The logger declaration in PerfExample1 and PerfExample2 is added but never used. Consider removing these unused imports and logger declarations to avoid dead code.



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample2.java:
##########
@@ -34,6 +36,8 @@
  */
 public class PerfExample2 extends PerfExampleBase {
 
+    private static final Logger LOG = Log.logger(PerfExample2.class);

Review Comment:
   Same issue as PerfExample1 - logger is declared but never used. Remove the unused import and logger declaration.



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample5.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.example;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.HugeFactory;
+import org.apache.hugegraph.type.define.Directions;
+import org.apache.hugegraph.util.Log;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.slf4j.Logger;
+
+/**

Review Comment:
   The comment says 'query vertices/adj-edges by ids' but this class only provides vertex and edge querying functionality. The comment should be more specific about what this example demonstrates compared to PerfExample3.



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample6.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.example;
+
+import org.apache.hugegraph.HugeFactory;
+import org.apache.hugegraph.util.Log;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.slf4j.Logger;
+
+/**
+ * Perf test for: query vertices/adj-edges by ids
+ */

Review Comment:
   The comment is identical to PerfExample5 but this class has different functionality (batch insertion with edges). Update the comment to accurately describe what PerfExample6 demonstrates.



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample6.java:
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.example;
+
+import org.apache.hugegraph.HugeFactory;
+import org.apache.hugegraph.util.Log;
+import org.apache.tinkerpop.gremlin.structure.T;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.slf4j.Logger;
+
+/**
+ * Perf test for: query vertices/adj-edges by ids
+ */
+public class PerfExample6 extends PerfExample5 {
+
+    private static final Logger LOG = Log.logger(PerfExample6.class);
+
+    /**
+     * Main method
+     * @param args 3 arguments, 1st should be 1, meaning single thread,
+     *             product of 2nd and 3rd is total number of "person" vertices
+     * @throws InterruptedException
+     */
+    public static void main(String[] args) throws Exception {
+        PerfExample6 tester = new PerfExample6();
+        tester.test(args);
+
+        // Stop daemon thread
+        HugeFactory.shutdown(30L);
+    }
+
+    @Override
+    protected void testInsert(GraphManager graph, int times, int multiple) {
+        final int TIMES = times * multiple;

Review Comment:
   Consider extracting the BATCH constant to a class-level constant or making it configurable, as hardcoded values like 100 reduce flexibility for performance testing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org


Re: [PR] perf(example): add PerfExample5 and PerfExample6 [incubator-hugegraph]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2860:
URL: https://github.com/apache/incubator-hugegraph/pull/2860#discussion_r2313262098


##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExampleBase.java:
##########
@@ -51,7 +51,7 @@ public abstract class PerfExampleBase {
     public static final int SOFTWARE_NUM = 30;
     public static final int EDGE_NUM = 100;
 
-    protected static final Logger LOG = Log.logger(PerfExampleBase.class);
+    private static final Logger LOG = Log.logger(PerfExampleBase.class);

Review Comment:
   Changing the Logger from 'protected' to 'private' breaks inheritance for subclasses that may need to access the logger. Consider keeping it protected or having subclasses define their own loggers.
   ```suggestion
       protected static final Logger LOG = Log.logger(PerfExampleBase.class);
   ```



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExampleBase.java:
##########
@@ -188,26 +190,29 @@ protected long execute(GraphManager graph, Consumer<Integer> task,
 
     protected abstract void testInsert(GraphManager graph, int times, int multiple);
 
-    protected void testQueryVertex(GraphManager graph, int threads, int thread, int multiple) {
-        int i = 0;
-        int j = 0;
-        int total = 0;
-        for (Object id : this.vertices) {
-            if (i++ % multiple != 0) {
-                continue;
-            }
-            if (j++ % threads != thread) {
-                continue;
-            }
-
-            LOG.debug("Query vertex {}: {}", i, id);
-            Vertex vertex = graph.queryVertex(id);
-            if (!vertex.id().equals(id)) {
-                LOG.warn("Query vertex by id {} returned {}", id, vertex);
+    protected void testQueryVertex(GraphManager graph,
+                                   int threads,
+                                   int thread,
+                                   int multiple) {
+        int totalV = 0;
+        long start = System.currentTimeMillis();
+        for (int i = 0; i < multiple; i++) {
+            int j = 0;
+            for (Object id : this.vertices) {
+                if (j++ % threads != thread) {
+                    continue;
+                }
+                LOG.debug("Query vertex {}: {}", i, id);
+                Vertex vertex = graph.queryVertex(id);
+                if (!vertex.id().equals(id)) {
+                    LOG.warn("Query vertex by id {} returned {}", id, vertex);
+                }
+                totalV++;
             }
-            total++;
         }
-        LOG.debug("Query vertices with thread({}): {}", thread, total);
+        long cost = elapsed(start);
+        LOG.info("Query {} vertices with thread({}): {} vertices/s",
+                 totalV, thread, totalV * 1000 / cost);

Review Comment:
   Division by zero error will occur if 'cost' is 0. Add a check to prevent division by zero before calculating vertices/s.
   ```suggestion
           if (cost == 0) {
               LOG.info("Query {} vertices with thread({}): N/A vertices/s (cost=0ms)", totalV, thread);
           } else {
               LOG.info("Query {} vertices with thread({}): {} vertices/s",
                        totalV, thread, totalV * 1000 / cost);
           }
   ```



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample5.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.example;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.HugeFactory;
+import org.apache.hugegraph.type.define.Directions;
+import org.apache.hugegraph.util.Log;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.slf4j.Logger;
+
+/**
+ * Perf test for: query vertices/adj-edges by ids
+ */
+public class PerfExample5 extends PerfExample3 {
+
+    private static final Logger LOG = Log.logger(PerfExample5.class);
+
+    /**
+     * Main method
+     * @param args 3 arguments, 1st should be 1, meaning single thread,
+     *             product of 2nd and 3rd is total number of "person" vertices
+     * @throws InterruptedException
+     */
+    public static void main(String[] args) throws Exception {
+        PerfExample5 tester = new PerfExample5();
+        tester.test(args);
+
+        // Stop daemon thread
+        HugeFactory.shutdown(30L);
+    }
+
+    @Override
+    protected void testQueryVertex(GraphManager graph,
+                                   int threads,
+                                   int thread,
+                                   int multiple) {
+        int totalV = 0;
+        long start = System.currentTimeMillis();
+        for (int i = 0; i < multiple; i++) {
+            int j = 0;
+            for (Object id : this.vertices) {
+                if (j++ % threads != thread) {
+                    continue;
+                }
+                graph.queryVertex(id);
+                totalV++;
+            }
+        }
+        long cost = elapsed(start);
+        LOG.info("Query {} vertices with thread({}): {} vertices/s",
+                 totalV, thread, totalV * 1000 / cost);
+    }
+
+    @Override
+    protected void testQueryEdge(GraphManager graph,
+                                 int threads,
+                                 int thread,
+                                 int multiple) {
+        int totalV = 0;
+        int totalE = 0;
+        long start = System.currentTimeMillis();
+
+        for (int i = 0; i < multiple; i++) {
+            int j = 0;
+            for (Object id : this.vertices) {
+                if (j++ % threads != thread) {
+                    continue;
+                }
+
+                Iterator<Edge> edges = graph.queryVertexEdge(id, Directions.OUT);
+                while (edges.hasNext()) {
+                    edges.next();
+                    totalE++;
+                }
+                totalV++;
+            }
+        }
+        long cost = elapsed(start);
+        LOG.info("Query {} edges of vertices({}) with thread({}): " +
+                 "{} vertices/s, {} edges/s",
+                 totalE, totalV, thread,
+                 totalV * 1000 / cost, totalE * 1000 / cost);

Review Comment:
   Division by zero error will occur if 'cost' is 0. Add a check to prevent division by zero before calculating vertices/s and edges/s.



##########
hugegraph-server/hugegraph-example/src/main/java/org/apache/hugegraph/example/PerfExample5.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hugegraph.example;
+
+import java.util.Iterator;
+
+import org.apache.hugegraph.HugeFactory;
+import org.apache.hugegraph.type.define.Directions;
+import org.apache.hugegraph.util.Log;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.slf4j.Logger;
+
+/**
+ * Perf test for: query vertices/adj-edges by ids
+ */
+public class PerfExample5 extends PerfExample3 {
+
+    private static final Logger LOG = Log.logger(PerfExample5.class);
+
+    /**
+     * Main method
+     * @param args 3 arguments, 1st should be 1, meaning single thread,
+     *             product of 2nd and 3rd is total number of "person" vertices
+     * @throws InterruptedException
+     */
+    public static void main(String[] args) throws Exception {
+        PerfExample5 tester = new PerfExample5();
+        tester.test(args);
+
+        // Stop daemon thread
+        HugeFactory.shutdown(30L);
+    }
+
+    @Override
+    protected void testQueryVertex(GraphManager graph,
+                                   int threads,
+                                   int thread,
+                                   int multiple) {
+        int totalV = 0;
+        long start = System.currentTimeMillis();
+        for (int i = 0; i < multiple; i++) {
+            int j = 0;
+            for (Object id : this.vertices) {
+                if (j++ % threads != thread) {
+                    continue;
+                }
+                graph.queryVertex(id);
+                totalV++;
+            }
+        }
+        long cost = elapsed(start);
+        LOG.info("Query {} vertices with thread({}): {} vertices/s",
+                 totalV, thread, totalV * 1000 / cost);

Review Comment:
   Division by zero error will occur if 'cost' is 0. Add a check to prevent division by zero before calculating vertices/s.
   ```suggestion
           if (cost == 0) {
               LOG.info("Query {} vertices with thread({}): N/A vertices/s (cost=0)", totalV, thread);
           } else {
               LOG.info("Query {} vertices with thread({}): {} vertices/s",
                        totalV, thread, totalV * 1000 / cost);
           }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org