Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
27e88072
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,发现更多精彩内容 >>
提交
27e88072
编写于
8月 11, 2009
作者:
Y
Yehuda Katz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Made benchmarks submodule so it's easier to keep in sync
上级
ccd1c5e5
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
4 addition
and
219 deletion
+4
-219
.gitmodules
.gitmodules
+3
-0
actionpack/examples
actionpack/examples
+1
-0
actionpack/examples/minimal.rb
actionpack/examples/minimal.rb
+0
-132
actionpack/examples/very_simple.rb
actionpack/examples/very_simple.rb
+0
-50
actionpack/examples/views/_collection.erb
actionpack/examples/views/_collection.erb
+0
-1
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
-12
actionpack/examples/views/_many_partials.erb
actionpack/examples/views/_many_partials.erb
+0
-10
actionpack/examples/views/_partial.erb
actionpack/examples/views/_partial.erb
+0
-10
actionpack/examples/views/layouts/alt.html.erb
actionpack/examples/views/layouts/alt.html.erb
+0
-1
actionpack/examples/views/layouts/kaigi.html.erb
actionpack/examples/views/layouts/kaigi.html.erb
+0
-1
actionpack/examples/views/template.html.erb
actionpack/examples/views/template.html.erb
+0
-1
未找到文件。
.gitmodules
0 → 100644
浏览文件 @
27e88072
[submodule "actionpack/examples"]
path = actionpack/examples
url = git://github.com/wycats/rails-simple-benches.git
examples
@
4e1327f0
Subproject commit 4e1327f06da6df1a1981d69c04e8d6463b38a4c1
actionpack/examples/minimal.rb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
# Pass NEW=1 to run with the new Base
ENV
[
'RAILS_ENV'
]
||=
'production'
ENV
[
'NO_RELOAD'
]
||=
'1'
$LOAD_PATH
.
unshift
"
#{
File
.
dirname
(
__FILE__
)
}
/../lib"
$LOAD_PATH
.
unshift
"
#{
File
.
dirname
(
__FILE__
)
}
/../../activesupport/lib"
require
'action_controller'
require
'action_controller/new_base'
if
ENV
[
'NEW'
]
require
'action_view'
require
'benchmark'
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
.
run
(
app
,
n
,
label
,
output
=
true
)
@output
=
output
puts
label
,
'='
*
label
.
size
if
label
env
=
Rack
::
MockRequest
.
env_for
(
"/"
).
merge
(
'n'
=>
n
,
'rack.input'
=>
StringIO
.
new
(
''
),
'rack.errors'
=>
$stdout
)
t
=
Benchmark
.
realtime
{
new
(
app
,
output
).
call
(
env
)
}
puts
"%d ms / %d req = %.1f usec/req"
%
[
10
**
3
*
t
,
n
,
10
**
6
*
t
/
n
]
puts
end
end
N
=
(
ENV
[
'N'
]
||
1000
).
to_i
module
ActionController::Rails2Compatibility
instance_methods
.
each
do
|
name
|
remove_method
name
end
end
class
BasePostController
<
ActionController
::
Base
append_view_path
"
#{
File
.
dirname
(
__FILE__
)
}
/views"
def
overhead
self
.
response_body
=
''
end
def
index
render
:text
=>
''
end
def
partial
render
:partial
=>
"/partial"
end
def
many_partials
render
:partial
=>
"/many_partials"
end
def
hundred_partials
render
:partial
=>
"/hundred_partials"
end
def
partial_collection
render
:partial
=>
"/collection"
,
:collection
=>
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
10
]
end
def
large_collection
render
:partial
=>
"/collection"
,
:collection
=>
(
1
...
1000
).
to_a
end
def
show_template
render
:template
=>
"template"
end
end
OK
=
[
200
,
{},
[]]
MetalPostController
=
lambda
{
OK
}
class
HttpPostController
<
ActionController
::
Metal
def
index
self
.
response_body
=
''
end
end
ActionController
::
Base
.
use_accept_header
=
false
unless
ENV
[
"PROFILE"
]
Runner
.
run
(
BasePostController
.
action
(
:overhead
),
1
,
'overhead'
,
false
)
Runner
.
run
(
BasePostController
.
action
(
:index
),
1
,
'index'
,
false
)
Runner
.
run
(
BasePostController
.
action
(
:show_template
),
1
,
'template'
,
false
)
Runner
.
run
(
BasePostController
.
action
(
:partial
),
1
,
'partial'
,
false
)
Runner
.
run
(
BasePostController
.
action
(
:many_partials
),
1
,
'many_partials'
,
false
)
Runner
.
run
(
BasePostController
.
action
(
:partial_collection
),
1
,
'collection'
,
false
)
Runner
.
run
(
BasePostController
.
action
(
:hundred_partials
),
1
,
'hundred_partials'
,
false
)
Runner
.
run
(
BasePostController
.
action
(
:large_collection
),
1
,
'large_collection'
,
false
)
(
ENV
[
"M"
]
||
1
).
to_i
.
times
do
Runner
.
run
(
BasePostController
.
action
(
:overhead
),
N
,
'overhead'
)
Runner
.
run
(
BasePostController
.
action
(
:index
),
N
,
'index'
)
Runner
.
run
(
BasePostController
.
action
(
:show_template
),
N
,
'template'
)
Runner
.
run
(
BasePostController
.
action
(
:partial
),
N
,
'partial'
)
Runner
.
run
(
BasePostController
.
action
(
:many_partials
),
N
,
'many_partials'
)
Runner
.
run
(
BasePostController
.
action
(
:partial_collection
),
N
,
'collection'
)
Runner
.
run
(
BasePostController
.
action
(
:hundred_partials
),
N
,
'hundred_partials'
)
Runner
.
run
(
BasePostController
.
action
(
:large_collection
),
N
,
'large_collection'
)
end
else
Runner
.
run
(
BasePostController
.
action
(
ENV
[
"PROFILE"
].
to_sym
),
1
,
ENV
[
"PROFILE"
])
require
"ruby-prof"
RubyProf
.
start
Runner
.
run
(
BasePostController
.
action
(
ENV
[
"PROFILE"
].
to_sym
),
N
,
ENV
[
"PROFILE"
])
result
=
RubyProf
.
stop
printer
=
RubyProf
::
CallStackPrinter
.
new
(
result
)
printer
.
print
(
File
.
open
(
"output.html"
,
"w"
))
end
\ No newline at end of file
actionpack/examples/very_simple.rb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
$:
.
push
"rails/activesupport/lib"
$:
.
push
"rails/actionpack/lib"
require
"action_controller"
class
Kaigi
<
ActionController
::
Metal
include
AbstractController
::
Callbacks
include
ActionController
::
RackConvenience
include
ActionController
::
RenderingController
include
ActionController
::
Layouts
include
ActionView
::
Context
before_filter
:set_name
append_view_path
"views"
def
view_context
self
end
def
controller
self
end
DEFAULT_LAYOUT
=
Object
.
new
.
tap
{
|
l
|
def
l
.
render
(
*
)
yield
end
}
def
render_template
(
template
,
layout
=
DEFAULT_LAYOUT
,
options
=
{},
partial
=
false
)
ret
=
template
.
render
(
self
,
{})
layout
.
render
(
self
,
{})
{
ret
}
end
def
index
render
:template
=>
"template"
end
def
alt
render
:template
=>
"template"
,
:layout
=>
"alt"
end
private
def
set_name
@name
=
params
[
:name
]
end
end
app
=
Rack
::
Builder
.
new
do
map
(
"/kaigi"
)
{
run
Kaigi
.
action
(
:index
)
}
map
(
"/kaigi/alt"
)
{
run
Kaigi
.
action
(
:alt
)
}
end
.
to_app
Rack
::
Handler
::
Mongrel
.
run
app
,
:Port
=>
3000
actionpack/examples/views/_collection.erb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
<%=
collection
%>
\ No newline at end of file
actionpack/examples/views/_hello.erb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
Hello
\ No newline at end of file
actionpack/examples/views/_hundred_partials.erb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
<%
10
.
times
do
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%
end
%>
\ No newline at end of file
actionpack/examples/views/_many_partials.erb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
<%=
render
:partial
=>
'/hello'
%>
\ No newline at end of file
actionpack/examples/views/_partial.erb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
<%=
"Hello"
%>
actionpack/examples/views/layouts/alt.html.erb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
+
<%=
yield
%>
+
\ No newline at end of file
actionpack/examples/views/layouts/kaigi.html.erb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
Hello
<%=
yield
%>
Goodbye
\ No newline at end of file
actionpack/examples/views/template.html.erb
已删除
100644 → 0
浏览文件 @
ccd1c5e5
Hello
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录