2014-12-30 :-)
_ tdiary が重い
たぶんうちだけなんだけど
日記を更新して「追記」をクリックしたあとにエラーになることがある。記録してない。その後「最新」を表示すると更新した内容が表示される。
とりあえずプロファイリングしただけ。
日記の表示
% echo date=20141229 | sudo -u www ruby -r profile ./index.rb >hoge.txt 2>&1
% cumulative self self total time seconds seconds calls ms/call ms/call name 29.06 6.62 6.62 114122 0.06 0.15 CGI.unescape 11.28 9.19 2.57 21039 0.12 0.41 String#gsub 8.52 11.13 1.94 10015 0.19 0.85 TDiary::RefererManager#add_referer 5.36 12.35 1.22 10015 0.12 1.56 #<Class:0xba35766c>::RefererDiary#add_referer 4.78 13.44 1.09 10018 0.11 3.42 #<TDiary::Plugin:0xba36f640>.referer_add_to_diary 3.34 14.20 0.76 94179 0.01 0.01 String#delete 3.12 14.91 0.71 94096 0.01 0.01 Array#pack 1.76 15.31 0.40 13 30.77 60.77 Hash#each 1.71 15.70 0.39 2325 0.17 0.76 Gem::Specification#initialize 1.54 16.05 0.35 439 0.80 31.73 Kernel#require 1.49 16.39 0.34 1798 0.19 33.95 Array#each 1.40 16.71 0.32 20227 0.02 0.02 String#sub 1.23 16.99 0.28 52538 0.01 0.01 Hash#[] 1.19 17.26 0.27 121 2.23 68.68 Kernel#gem_original_require 1.14 17.52 0.26 23585 0.01 0.02 Hash#[]= 1.10 17.77 0.25 41581 0.01 0.01 String#force_encoding 0.92 17.98 0.21 20032 0.01 0.01 String#tr 0.92 18.19 0.21 5363 0.04 0.08 nil# 0.88 18.39 0.20 4545 0.04 0.13 Array#hash
CGI.unescape はここ。wiki 書式使ってはいる。ふうむ
% cd tdiary-core % grep -r CGI.unescape * lib/tdiary/style/wiki.rb: "<%=#{CGI.unescapeHTML($1)}\n%>" lib/tdiary/style/wiki.rb: "<p><%=#{CGI.unescapeHTML($1)}\n%></p>"
日記の追記
lib/tdiary/admin.rb に仕込んでみる。
# # class TDiaryAppend # append diary # require 'profiler' class TDiaryAppend < TDiaryUpdate def initialize( cgi, rhtml, conf ) Profiler__::start_profile begin super rescue TDiaryError @date = newdate end @author = @conf.multi_user ? @cgi.remote_user : nil @io.transaction( @date ) do |diaries| @diaries = diaries @diary = self[@date] || @io.diary_factory( @date, @title, '', @conf.style ) self << @diary.append( @body, @author ) @diary.set_title( @title ) unless @title.empty? @diary.show( ! @hide ) DIRTY_DIARY end File.open("hoge.txt", "w") {|f| Profiler__::print_profile(f) } Profiler__::stop_profile end protected def newdate Time::now + (@conf.hour_offset * 3600).to_i end end
結果。うーん?
% cumulative self self total time seconds seconds calls ms/call ms/call name 40.00 0.22 0.22 1 220.00 380.00 Marshal.dump 29.09 0.38 0.16 12602 0.01 0.01 Kernel#respond_to_missing? 5.45 0.41 0.03 2 15.00 25.00 Marshal.load 3.64 0.43 0.02 140 0.14 0.14 Time._load 3.64 0.45 0.02 241 0.08 0.08 IO#puts 1.82 0.46 0.01 62 0.16 0.16 HikiDoc::LineInput#gets 1.82 0.47 0.01 6 1.67 3.33 HikiDoc#compile_header 1.82 0.48 0.01 13 0.77 0.77 HikiDoc#rstrip 1.82 0.49 0.01 61 0.16 1.31 TDiary::IO::Default#store 1.82 0.50 0.01 9 1.11 1.11 HikiDoc::HTMLOutput#initialize 1.82 0.51 0.01 3 3.33 3.33 SystemCallError#initialize 1.82 0.52 0.01 2 5.00 5.00 Dir.glob 1.82 0.53 0.01 1 10.00 10.00 Hash#each 1.82 0.54 0.01 61 0.16 0.98 Array#each 1.82 0.55 0.01 6 1.67 146.67 PStore#transaction 1.82 0.56 0.01 2 5.00 25.00 PStore#load_data 0.00 0.56 0.00 1 0.00 0.00 TDiary::Style::BaseDiary#set_title 0.00 0.56 0.00 62 0.00 0.00 String#sub 0.00 0.56 0.00 6 0.00 0.00 IO#set_encoding 0.00 0.56 0.00 5 0.00 0.00 Class#inherited 0.00 0.56 0.00 47 0.00 0.00 Module#method_added 0.00 0.56 0.00 3 0.00 0.00 Module#attr_reader 0.00 0.56 0.00 2 0.00 0.00 Module#private 0.00 0.56 0.00 4 0.00 0.00 Kernel#require 0.00 0.56 0.00 1 0.00 0.00 TracePoint#enable 0.00 0.56 0.00 4 0.00 0.00 Array#flatten 0.00 0.56 0.00 1 0.00 0.00 Module#constants 0.00 0.56 0.00 8 0.00 0.00 Symbol#slice 0.00 0.56 0.00 26 0.00 0.00 Regexp#=~ 0.00 0.56 0.00 5 0.00 0.00 Kernel#!~ 0.00 0.56 0.00 5 0.00 0.00 Module#const_get 0.00 0.56 0.00 8 0.00 0.00 Module#append_features 0.00 0.56 0.00 8 0.00 0.00 Module#included 0.00 0.56 0.00 8 0.00 0.00 Module#include 0.00 0.56 0.00 3 0.00 0.00 Module#const_defined? 0.00 0.56 0.00 10 0.00 0.00 String#downcase 0.00 0.56 0.00 7 0.00 0.00 Hash#[]= 0.00 0.56 0.00 1 0.00 10.00 TDiary::IO::Base#initialize 0.00 0.56 0.00 67 0.00 0.90 Class#new 0.00 0.56 0.00 1 0.00 10.00 TDiary::TDiaryBase#initialize 0.00 0.56 0.00 5 0.00 0.00 Fixnum#& 0.00 0.56 0.00 1 0.00 0.00 CGI::QueryExtension#referer 0.00 0.56 0.00 2 0.00 0.00 TDiary::ViewHelper#base_url 0.00 0.56 0.00 4 0.00 0.00 String#=== 0.00 0.56 0.00 190 0.00 0.00 Regexp#=== 0.00 0.56 0.00 4 0.00 0.00 MatchData#[] 0.00 0.56 0.00 4 0.00 0.00 URI::Parser#split 0.00 0.56 0.00 6 0.00 0.00 URI.scheme_list 0.00 0.56 0.00 6 0.00 0.00 String#upcase
参考
[ツッコミを入れる]