add performance test for dtext, fixes #2051

This commit is contained in:
r888888888
2013-12-03 15:50:58 -08:00
parent 1613116266
commit 327b52c2d3
8 changed files with 79 additions and 19 deletions

View File

@@ -10,6 +10,8 @@ group :test do
gem "vcr"
gem "webmock"
gem "timecop"
gem "test-unit-rails"
gem "ruby-prof"
end
group :assets do

View File

@@ -52,6 +52,12 @@ GEM
net-ssh-gateway (>= 1.1.0)
capistrano-unicorn (0.1.10)
capistrano
capybara (2.2.0)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
chronic (0.9.1)
coderay (1.0.9)
crack (0.4.1)
@@ -148,6 +154,7 @@ GEM
json (~> 1.4)
ref (1.0.5)
rmagick (2.13.2)
rr (1.1.2)
ruby-prof (0.13.0)
safe_yaml (0.9.5)
sanitize (2.0.6)
@@ -179,6 +186,25 @@ GEM
statistics2 (0.54)
term-ansicolor (1.2.2)
tins (~> 0.8)
test-unit (2.5.5)
test-unit-activesupport (1.0.1)
activesupport
test-unit
test-unit-capybara (1.0.4)
capybara (>= 2.1.0)
json
test-unit (>= 2.5.3)
test-unit-notify (1.0.1)
test-unit (>= 2.4.9)
test-unit-rails (1.0.2)
rails
test-unit-activesupport
test-unit-capybara
test-unit-notify
test-unit-rr
test-unit-rr (1.0.3)
rr (>= 1.1.1)
test-unit (>= 2.5.2)
therubyracer (0.11.4)
libv8 (~> 3.11.8.12)
ref
@@ -209,6 +235,8 @@ GEM
activesupport (>= 2.3.4)
chronic (>= 0.6.3)
xml-simple (1.1.2)
xpath (2.0.0)
nokogiri (~> 1.3)
PLATFORMS
ruby
@@ -245,6 +273,7 @@ DEPENDENCIES
simplecov
statistics2
term-ansicolor
test-unit-rails
therubyracer
timecop
uglifier (>= 1.0.3)

View File

@@ -122,3 +122,8 @@ table tfoot {
color: #666;
font-style: italic;
}
.tn {
font-size: 0.8em;
color: gray;
}

View File

@@ -18,11 +18,6 @@ div#note-container {
line-height: normal;
}
p.tn {
font-size: 0.8em;
color: gray;
}
> :last-child {
margin-bottom: 0;
}

View File

@@ -19,6 +19,7 @@ class DText
str.gsub!(/\[i\](.+?)\[\/i\]/i, '<em>\1</em>')
str.gsub!(/\[s\](.+?)\[\/s\]/i, '<s>\1</s>')
str.gsub!(/\[u\](.+?)\[\/u\]/i, '<u>\1</u>')
str.gsub!(/\[tn\](.+?)\[\/tn\]/i, '<p class="tn">\1</p>')
str = parse_links(str)
str = parse_aliased_wiki_links(str)

View File

@@ -4364,10 +4364,10 @@ CREATE INDEX index_comments_on_body_index ON comments USING gin (body_index);
--
-- Name: index_comments_on_creator_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
-- Name: index_comments_on_creator_id_and_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_comments_on_creator_id ON comments USING btree (creator_id);
CREATE INDEX index_comments_on_creator_id_and_post_id ON comments USING btree (creator_id, post_id);
--
@@ -5897,10 +5897,10 @@ CREATE INDEX index_notes_on_body_index ON notes USING gin (body_index);
--
-- Name: index_notes_on_creator_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
-- Name: index_notes_on_creator_id_and_post_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
--
CREATE INDEX index_notes_on_creator_id ON notes USING btree (creator_id);
CREATE INDEX index_notes_on_creator_id_and_post_id ON notes USING btree (creator_id, post_id);
--
@@ -6558,4 +6558,6 @@ INSERT INTO schema_migrations (version) VALUES ('20131006193238');
INSERT INTO schema_migrations (version) VALUES ('20131117150705');
INSERT INTO schema_migrations (version) VALUES ('20131118153503');
INSERT INTO schema_migrations (version) VALUES ('20131118153503');
INSERT INTO schema_migrations (version) VALUES ('20131130190411');

View File

@@ -1,9 +0,0 @@
require 'test_helper'
require 'rails/performance_test_help'
# Profiling results for each test method are written to tmp/performance.
class BrowsingTest < ActionController::PerformanceTest
def test_homepage
get '/'
end
end

View File

@@ -0,0 +1,35 @@
require 'test_helper'
require 'rails/performance_test_help'
class DtextTest < ActionDispatch::PerformanceTest
self.profile_options = {
:runs => 5
}
# Refer to the documentation for all available options
# self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory]
# :output => 'tmp/performance', :formats => [:flat] }
def setup
base_text = <<-EOS
[b]Lorem ipsum[/b] dolor sit amet, "consectetur":http://www.google.com adipisicing elit, sed do eiusmod
tempor incididunt ut labore et [[dolore]] [[magna|MAGNA]] aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco {{laboris}} nisi ut aliquip ex ea commodo
h1. consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
[quote]proident, sunt in culpa qui officia deserunt mollit anim id est laborum.[/quote]
* list of items
** list of items
*** list of items
** list of items user #1234
* list of items post #1234
[spoiler]this is a spoiler[/spoiler]
EOS
@text = base_text * 1000
end
def test_parse
DText.parse(@text)
end
end