Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
7dedfded
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7dedfded
编写于
8月 07, 2012
作者:
D
David Heinemeier Hansson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove antiquated example code
上级
42c30881
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
0 addition
and
219 deletion
+0
-219
actionpack/examples/performance.rb
actionpack/examples/performance.rb
+0
-185
actionpack/examples/views/_collection.erb
actionpack/examples/views/_collection.erb
+0
-3
actionpack/examples/views/_hello.erb
actionpack/examples/views/_hello.erb
+0
-1
actionpack/examples/views/_hundred_partials.erb
actionpack/examples/views/_hundred_partials.erb
+0
-3
actionpack/examples/views/_partial.erb
actionpack/examples/views/_partial.erb
+0
-10
actionpack/examples/views/_ten_partials.erb
actionpack/examples/views/_ten_partials.erb
+0
-10
actionpack/examples/views/hashes/_hash.erb
actionpack/examples/views/hashes/_hash.erb
+0
-3
actionpack/examples/views/my_hashes/_my_hash.erb
actionpack/examples/views/my_hashes/_my_hash.erb
+0
-3
actionpack/examples/views/template.html.erb
actionpack/examples/views/template.html.erb
+0
-1
未找到文件。
actionpack/examples/performance.rb
已删除
100644 → 0
浏览文件 @
42c30881
ENV
[
'RAILS_ENV'
]
||=
'production'
require
File
.
expand_path
(
'../../../load_paths'
,
__FILE__
)
require
'action_pack'
require
'action_controller'
require
'action_view'
require
'active_model'
require
'benchmark'
MyHash
=
Class
.
new
(
Hash
)
Hash
.
class_eval
do
extend
ActiveModel
::
Naming
include
ActiveModel
::
Conversion
end
class
Runner
def
initialize
(
app
,
output
)
@app
,
@output
=
app
,
output
end
def
puts
(
*
)
super
if
@output
end
def
call
(
env
)
env
[
'n'
].
to_i
.
times
{
@app
.
call
(
env
)
}
@app
.
call
(
env
).
tap
{
|
response
|
report
(
env
,
response
)
}
end
def
report
(
env
,
response
)
return
unless
ENV
[
"DEBUG"
]
out
=
env
[
'rack.errors'
]
out
.
puts
response
[
0
],
response
[
1
].
to_yaml
,
'---'
response
[
2
].
each
{
|
part
|
out
.
puts
part
}
out
.
puts
'---'
end
def
self
.
puts
(
*
)
super
if
@output
end
def
self
.
print
(
*
)
super
if
@output
end
def
self
.
app_and_env_for
(
action
,
n
)
env
=
Rack
::
MockRequest
.
env_for
(
"/"
)
env
.
merge!
(
'n'
=>
n
,
'rack.input'
=>
StringIO
.
new
(
''
),
'rack.errors'
=>
$stdout
)
app
=
lambda
{
|
env
|
BasePostController
.
action
(
action
).
call
(
env
)
}
return
app
,
env
end
$ran
=
[]
def
self
.
run
(
action
,
n
,
output
=
true
)
print
"."
STDOUT
.
flush
@output
=
output
label
=
action
.
to_s
app
,
env
=
app_and_env_for
(
action
,
n
)
t
=
Benchmark
.
realtime
{
new
(
app
,
output
).
call
(
env
)
}
$ran
<<
[
label
,
(
t
*
1000
).
to_i
.
to_s
]
if
output
end
def
self
.
done
puts
header
,
content
=
""
,
""
$ran
.
each
do
|
k
,
v
|
size
=
[
k
.
size
,
v
.
size
].
max
+
1
header
<<
format
(
"%
#{
size
}
s"
,
k
)
content
<<
format
(
"%
#{
size
}
s"
,
v
)
end
puts
header
puts
content
end
end
ActionController
::
Base
.
logger
=
nil
ActionController
::
Base
.
config
.
compile_methods!
ActionView
::
Resolver
.
caching
=
ENV
[
"RAILS_ENV"
]
==
"production"
class
BasePostController
<
ActionController
::
Base
append_view_path
"
#{
File
.
dirname
(
__FILE__
)
}
/views"
def
overhead
self
.
response_body
=
''
end
def
index
render
:text
=>
''
end
$OBJECT
=
{
:name
=>
"Hello my name is omg"
,
:address
=>
"333 omg"
}
def
partial
render
:partial
=>
"/collection"
,
:object
=>
$OBJECT
end
def
partial_10
render
:partial
=>
"/ten_partials"
end
def
partial_100
render
:partial
=>
"/hundred_partials"
end
$COLLECTION1
=
[]
10
.
times
do
|
i
|
$COLLECTION1
<<
{
:name
=>
"Hello my name is omg"
,
:address
=>
"333 omg"
}
end
def
coll_10
render
:partial
=>
"/collection"
,
:collection
=>
$COLLECTION1
end
$COLLECTION2
=
[]
100
.
times
do
|
i
|
$COLLECTION2
<<
{
:name
=>
"Hello my name is omg"
,
:address
=>
"333 omg"
}
end
def
coll_100
render
:partial
=>
"/collection"
,
:collection
=>
$COLLECTION2
end
def
uniq_100
render
:partial
=>
$COLLECTION2
end
$COLLECTION3
=
[]
50
.
times
do
|
i
|
$COLLECTION3
<<
{
:name
=>
"Hello my name is omg"
,
:address
=>
"333 omg"
}
$COLLECTION3
<<
MyHash
.
new
(
:name
=>
"Hello my name is omg"
,
:address
=>
"333 omg"
)
end
def
diff_100
render
:partial
=>
$COLLECTION3
end
def
template_1
render
:template
=>
"template"
end
module
Foo
def
omg
"omg"
end
end
helper
Foo
end
N
=
(
ENV
[
'N'
]
||
1000
).
to_i
# ActionController::Base.use_accept_header = false
def
run_all!
(
times
,
verbose
)
Runner
.
run
(
:overhead
,
times
,
verbose
)
Runner
.
run
(
:index
,
times
,
verbose
)
Runner
.
run
(
:template_1
,
times
,
verbose
)
Runner
.
run
(
:partial
,
times
,
verbose
)
Runner
.
run
(
:partial_10
,
times
,
verbose
)
Runner
.
run
(
:coll_10
,
times
,
verbose
)
Runner
.
run
(
:partial_100
,
times
,
verbose
)
Runner
.
run
(
:coll_100
,
times
,
verbose
)
Runner
.
run
(
:uniq_100
,
times
,
verbose
)
Runner
.
run
(
:diff_100
,
times
,
verbose
)
end
if
ENV
[
"PROFILE"
]
Runner
.
run
(
ENV
[
"PROFILE"
].
to_sym
,
1
,
false
)
require
"ruby-prof"
RubyProf
.
start
Runner
.
run
(
ENV
[
"PROFILE"
].
to_sym
,
N
,
true
)
result
=
RubyProf
.
stop
printer
=
RubyProf
::
CallStackPrinter
.
new
(
result
)
printer
.
print
(
File
.
open
(
"output.html"
,
"w"
))
else
run_all!
(
1
,
false
)
(
ENV
[
"M"
]
||
1
).
to_i
.
times
do
$ran
=
[]
run_all!
(
N
,
true
)
Runner
.
done
end
end
\ No newline at end of file
actionpack/examples/views/_collection.erb
已删除
100644 → 0
浏览文件 @
42c30881
<%=
collection
[
:name
]
%>
<%=
collection
[
:address
]
%>
<%=
omg
%>
\ No newline at end of file
actionpack/examples/views/_hello.erb
已删除
100644 → 0
浏览文件 @
42c30881
Hello
\ No newline at end of file
actionpack/examples/views/_hundred_partials.erb
已删除
100644 → 0
浏览文件 @
42c30881
<%
100
.
times
do
%>
<%=
render
:partial
=>
"/collection"
,
:object
=>
$OBJECT
%>
<%
end
%>
\ No newline at end of file
actionpack/examples/views/_partial.erb
已删除
100644 → 0
浏览文件 @
42c30881
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
actionpack/examples/views/_ten_partials.erb
已删除
100644 → 0
浏览文件 @
42c30881
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
<%=
render
:partial
=>
'/collection'
,
:object
=>
$OBJECT
%>
\ No newline at end of file
actionpack/examples/views/hashes/_hash.erb
已删除
100644 → 0
浏览文件 @
42c30881
<%=
hash
[
:name
]
%>
<%=
hash
[
:address
]
%>
<%=
omg
%>
\ No newline at end of file
actionpack/examples/views/my_hashes/_my_hash.erb
已删除
100644 → 0
浏览文件 @
42c30881
<%=
my_hash
[
:name
]
%>
<%=
my_hash
[
:address
]
%>
<%=
omg
%>
\ No newline at end of file
actionpack/examples/views/template.html.erb
已删除
100644 → 0
浏览文件 @
42c30881
Hello
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录