Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个模型 Post 在视图中,我还想显示将新帖子记录到数据库所花费的时间。
如何衡量创建@post 的新实例所花费的时间?
您可以使用 Ruby 的基准测试
timing = Benchmark.measure { Post.new }
基准文档
或者您可以使用手动计时。
start = Time.now @post = Post.new finish = Time.now timeTaken = finish - start
gem 'rack-mini-profiler' $ bundle 只需重新启动您的应用程序,看看您在哪里浪费时间。
gem 'rack-mini-profiler'
$ bundle
有关更多信息http://railscasts.com/episodes/368-miniprofiler
我有两个元素,我想通过使第二个元素水平移动固定数量的像素<table>,以特定方式垂直排列它们。<table>
<table>
例如:
<table id="table1" align="center"> ... </table> <table id="table2" style="padding-