Created
October 2, 2010 01:18
-
-
Save paulbaumgart/607137 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'fileutils' | |
dir = File.dirname(File.expand_path(__FILE__)) | |
$LOAD_PATH.unshift(File.join(dir, 'lib')) | |
$LOAD_PATH.unshift(dir) | |
require 'gollum' | |
NUM_PAGES=1000 | |
TEST_REPO_PATH="test.git" | |
def set_up | |
FileUtils.rm_rf(TEST_REPO_PATH) | |
Grit::Repo.init_bare(TEST_REPO_PATH) | |
@shared_wiki = Gollum::Wiki.new(TEST_REPO_PATH) | |
# create large repo | |
index = @shared_wiki.repo.index | |
NUM_PAGES.times do |i| | |
index.add("Page-#{i}.md", "Page #{i}") | |
end | |
index.commit("Added #{NUM_PAGES} pages.") | |
end | |
def tear_down | |
FileUtils.rm_r(TEST_REPO_PATH) | |
end | |
def time description | |
set_up | |
start = Time.now | |
yield | |
puts "\"#{description}\" executed in: #{Time.now - start} seconds" | |
tear_down | |
end | |
def assert_non_nil object | |
raise AssertionError.new("something is nil that shouldn't be") unless object != nil | |
end | |
%[git checkout long-term-tree-caching] | |
time "100 reads _with_ tree caching" do | |
100.times do |i| | |
wiki = @shared_wiki | |
assert_non_nil wiki.page("Page #{i}") | |
end | |
end | |
time "25 writes followed by reads _with_ tree caching" do | |
25.times do |i| | |
wiki = @shared_wiki | |
wiki.write_page("New Page #{i}", :markdown, "New Page #{i}") | |
assert_non_nil wiki.page("New Page #{i}") | |
end | |
end | |
%[git checkout master] | |
time "100 reads _without_ tree caching" do | |
100.times do |i| | |
wiki = Gollum::Wiki.new(TEST_REPO_PATH) | |
assert_non_nil wiki.page("Page #{i}") | |
end | |
end | |
time "25 writes followed by reads _without_ tree caching" do | |
25.times do |i| | |
wiki = Gollum::Wiki.new(TEST_REPO_PATH) | |
wiki.write_page("New Page #{i}", :markdown, "New Page #{i}") | |
assert_non_nil wiki.page("New Page #{i}") | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment