[Groonga-commit] groonga/groonga [master] add invalid value check.

アーカイブの一覧に戻る

null+****@clear***** null+****@clear*****
2011年 6月 27日 (月) 19:34:17 JST


Kouhei Sutou	2011-06-27 10:34:17 +0000 (Mon, 27 Jun 2011)

  New Revision: 71b9031a8845bb848bf99a64699ddd1d39db1dde

  Log:
    add invalid value check.

  Modified files:
    tools/groonga-query-log-analyzer

  Modified: tools/groonga-query-log-analyzer (+11 -2)
===================================================================
--- tools/groonga-query-log-analyzer    2011-06-27 10:15:08 +0000 (9c879a1)
+++ tools/groonga-query-log-analyzer    2011-06-27 10:34:17 +0000 (4882296)
@@ -529,7 +529,11 @@ class GroongaQueryLogAnaylzer
     end
 
     def slow_response_ratio
-      (@n_slow_responses.to_f / @n_responses) * 100
+      if @n_responses.zero?
+        0
+      else
+        (@n_slow_responses.to_f / @n_responses) * 100
+      end
     end
 
     def period
@@ -987,7 +991,12 @@ class GroongaQueryLogAnaylzer
     end
 
     def format_time(time)
-      colorize(time.strftime("%Y-%m-%d %H:%M:%S.%u"), :time)
+      if time.nil?
+        formatted_time = "NaN"
+      else
+        formatted_time = time.strftime("%Y-%m-%d %H:%M:%S.%u")
+      end
+      colorize(formatted_time, :time)
     end
 
     def colorize(text, schema_name)




Groonga-commit メーリングリストの案内
アーカイブの一覧に戻る