add performance test for dtext, fixes #2051
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -10,6 +10,8 @@ group :test do
|
|||||||
gem "vcr"
|
gem "vcr"
|
||||||
gem "webmock"
|
gem "webmock"
|
||||||
gem "timecop"
|
gem "timecop"
|
||||||
|
gem "test-unit-rails"
|
||||||
|
gem "ruby-prof"
|
||||||
end
|
end
|
||||||
|
|
||||||
group :assets do
|
group :assets do
|
||||||
|
|||||||
29
Gemfile.lock
29
Gemfile.lock
@@ -52,6 +52,12 @@ GEM
|
|||||||
net-ssh-gateway (>= 1.1.0)
|
net-ssh-gateway (>= 1.1.0)
|
||||||
capistrano-unicorn (0.1.10)
|
capistrano-unicorn (0.1.10)
|
||||||
capistrano
|
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)
|
chronic (0.9.1)
|
||||||
coderay (1.0.9)
|
coderay (1.0.9)
|
||||||
crack (0.4.1)
|
crack (0.4.1)
|
||||||
@@ -148,6 +154,7 @@ GEM
|
|||||||
json (~> 1.4)
|
json (~> 1.4)
|
||||||
ref (1.0.5)
|
ref (1.0.5)
|
||||||
rmagick (2.13.2)
|
rmagick (2.13.2)
|
||||||
|
rr (1.1.2)
|
||||||
ruby-prof (0.13.0)
|
ruby-prof (0.13.0)
|
||||||
safe_yaml (0.9.5)
|
safe_yaml (0.9.5)
|
||||||
sanitize (2.0.6)
|
sanitize (2.0.6)
|
||||||
@@ -179,6 +186,25 @@ GEM
|
|||||||
statistics2 (0.54)
|
statistics2 (0.54)
|
||||||
term-ansicolor (1.2.2)
|
term-ansicolor (1.2.2)
|
||||||
tins (~> 0.8)
|
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)
|
therubyracer (0.11.4)
|
||||||
libv8 (~> 3.11.8.12)
|
libv8 (~> 3.11.8.12)
|
||||||
ref
|
ref
|
||||||
@@ -209,6 +235,8 @@ GEM
|
|||||||
activesupport (>= 2.3.4)
|
activesupport (>= 2.3.4)
|
||||||
chronic (>= 0.6.3)
|
chronic (>= 0.6.3)
|
||||||
xml-simple (1.1.2)
|
xml-simple (1.1.2)
|
||||||
|
xpath (2.0.0)
|
||||||
|
nokogiri (~> 1.3)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
@@ -245,6 +273,7 @@ DEPENDENCIES
|
|||||||
simplecov
|
simplecov
|
||||||
statistics2
|
statistics2
|
||||||
term-ansicolor
|
term-ansicolor
|
||||||
|
test-unit-rails
|
||||||
therubyracer
|
therubyracer
|
||||||
timecop
|
timecop
|
||||||
uglifier (>= 1.0.3)
|
uglifier (>= 1.0.3)
|
||||||
|
|||||||
@@ -122,3 +122,8 @@ table tfoot {
|
|||||||
color: #666;
|
color: #666;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tn {
|
||||||
|
font-size: 0.8em;
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,11 +18,6 @@ div#note-container {
|
|||||||
line-height: normal;
|
line-height: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.tn {
|
|
||||||
font-size: 0.8em;
|
|
||||||
color: gray;
|
|
||||||
}
|
|
||||||
|
|
||||||
> :last-child {
|
> :last-child {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class DText
|
|||||||
str.gsub!(/\[i\](.+?)\[\/i\]/i, '<em>\1</em>')
|
str.gsub!(/\[i\](.+?)\[\/i\]/i, '<em>\1</em>')
|
||||||
str.gsub!(/\[s\](.+?)\[\/s\]/i, '<s>\1</s>')
|
str.gsub!(/\[s\](.+?)\[\/s\]/i, '<s>\1</s>')
|
||||||
str.gsub!(/\[u\](.+?)\[\/u\]/i, '<u>\1</u>')
|
str.gsub!(/\[u\](.+?)\[\/u\]/i, '<u>\1</u>')
|
||||||
|
str.gsub!(/\[tn\](.+?)\[\/tn\]/i, '<p class="tn">\1</p>')
|
||||||
|
|
||||||
str = parse_links(str)
|
str = parse_links(str)
|
||||||
str = parse_aliased_wiki_links(str)
|
str = parse_aliased_wiki_links(str)
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
@@ -6559,3 +6559,5 @@ INSERT INTO schema_migrations (version) VALUES ('20131006193238');
|
|||||||
INSERT INTO schema_migrations (version) VALUES ('20131117150705');
|
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');
|
||||||
@@ -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
|
|
||||||
35
test/performance/dtext_test.rb
Normal file
35
test/performance/dtext_test.rb
Normal 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
|
||||||
Reference in New Issue
Block a user