#!/usr/bin/env ruby
# Copyright (C) 2003-2005 Kouichirou Eto, All rights reserved.

$LOAD_PATH.unshift("../../compat") unless $LOAD_PATH.include?("../../compat")
$LOAD_PATH << "../../lib" unless $LOAD_PATH.include?("../../lib")
require "qwik/page"
require "qwik/test-module-session"
require "qwik/test-module-bench"

class BenchPages
  include TestSession
  include BenchmarkTest

  def setup
    @config = Qwik::Config.new(true)
    @dir = "./test/".path
    @wwwdir = @dir
    setup_dir(@dir)
    @pages = Qwik::Pages.new(@config, @dir)
  end

  def bench_all
    n = 1000
#    page = @pages.create_new
#    page.store("*t")
    page = @pages["TextFormat"]
    benchmark {
      n.times {
	title = page.get_title
#	title = page.key
      }
    }
#    @pages.close if @pages
    @pages.erase_all if @pages
  end
end

b = BenchPages.new
b.setup
b.bench_all
b.teardown
