Copilot commented on code in PR #241:
URL: 
https://github.com/apache/incubator-hugegraph-ai/pull/241#discussion_r2095724845


##########
hugegraph-llm/src/hugegraph_llm/utils/decorators.py:
##########
@@ -76,18 +76,18 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
         return result
     return wrapper
 
-
-def record_qps(func: Callable) -> Callable:
+def record_rpm(func: Callable) -> Callable:
     @wraps(func)
     def wrapper(*args: Any, **kwargs: Any) -> Any:
         start = time.perf_counter()
         result = func(*args, **kwargs)
         call_count = result.get("call_count", 0)
-        qps = call_count / (time.perf_counter() - start)
-        if qps >= 0.10:
-            log.debug("%s QPS: %.2f/s", args[0].__class__.__name__, qps)
+        elapsed_time = time.perf_counter() - start
+        rpm = (call_count / elapsed_time * 60) if elapsed_time > 0 else 0
+        if rpm >= 6.0:
+            log.debug("%s RPM: %.2f/min", args[0].__class__.__name__, rpm)
         else:
-            log.debug("%s QPS: %f/s", args[0].__class__.__name__, qps)
+            log.debug("%s RPM: %f/min", args[0].__class__.__name__, rpm)

Review Comment:
   [nitpick] The `"%f"` specifier defaults to six decimal places, which is 
inconsistent with the upstream `"%.2f"`. For readability, use `"%.2f/min"` here 
as well.
   ```suggestion
               log.debug("%s RPM: %.2f/min", args[0].__class__.__name__, rpm)
   ```



##########
hugegraph-llm/src/hugegraph_llm/utils/decorators.py:
##########
@@ -76,18 +76,18 @@ def wrapper(*args: Any, **kwargs: Any) -> Any:
         return result
     return wrapper
 
-
-def record_qps(func: Callable) -> Callable:
+def record_rpm(func: Callable) -> Callable:
     @wraps(func)
     def wrapper(*args: Any, **kwargs: Any) -> Any:
         start = time.perf_counter()

Review Comment:
   The decorator only provides a synchronous wrapper; if `func` is an async 
function, it won't be awaited correctly. Consider mirroring the `log_time` 
pattern to support both sync and async functions.
   ```suggestion
       async def async_wrapper(*args: Any, **kwargs: Any) -> Any:
           start = time.perf_counter()
           result = await func(*args, **kwargs)
           call_count = result.get("call_count", 0)
           elapsed_time = time.perf_counter() - start
           rpm = (call_count / elapsed_time * 60) if elapsed_time > 0 else 0
           if rpm >= 6.0:
               log.debug("%s RPM: %.2f/min", args[0].__class__.__name__, rpm)
           else:
               log.debug("%s RPM: %f/min", args[0].__class__.__name__, rpm)
           return result
   
       @wraps(func)
       def sync_wrapper(*args: Any, **kwargs: Any) -> Any:
           start = time.perf_counter()
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to