[Groonga-commit] droonga/fluent-plugin-droonga at 0515441 [master] Benchmark: setup database without shell commands

Back to archive index

YUKI Hiroshi null+****@clear*****
Fri Oct 25 18:39:56 JST 2013


YUKI Hiroshi	2013-10-25 18:39:56 +0900 (Fri, 25 Oct 2013)

  New Revision: 0515441976a52af00d533cd1119c4fe9a8cdc0ff
  https://github.com/droonga/fluent-plugin-droonga/commit/0515441976a52af00d533cd1119c4fe9a8cdc0ff

  Message:
    Benchmark: setup database without shell commands

  Modified files:
    benchmark/utils.rb

  Modified: benchmark/utils.rb (+13 -11)
===================================================================
--- benchmark/utils.rb    2013-10-25 18:35:04 +0900 (a993e7a)
+++ benchmark/utils.rb    2013-10-25 18:39:56 +0900 (5c9ad51)
@@ -26,18 +26,20 @@ module DroongaBenchmark
   class WatchDatabase
     attr_reader :context
 
-    def initialize(n_times)
-      setup_database
-      @context = Groonga::Context.new
-      @context.open_database("#{@database_path}/db")
-    end
-
-    def setup_database
-      @database_path = "/tmp/watch-benchmark"
+    def initialize
+      @database_dir = "/tmp/watch-benchmark"
+      @database_path = "#{database_dir}/db"
       @ddl_path = File.expand_path(File.join(__FILE__, "..", "..", "ddl", "watchdb.grn"))
-      FileUtils.rm_rf(@database_path)
-      FileUtils.mkdir_p(@database_path)
-      `cat #{@ddl_path} | groonga -n #{@database_path}/db`
+      FileUtils.rm_rf(@database_dir)
+      FileUtils.mkdir_p(@database_dir)
+
+      Groonga::Database.create(:path => @database_path)
+
+      @context = Groonga::Context.new
+      @context.open_database(@database_path)
+      File.open(@ddl_path) do |ddl|
+       @context.restore(ddl)
+      end
     end
 
     def subscribe(term)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index