2016-11-08 35 views
0

有什麼辦法 - Laravel中的一些模塊/插件,它測量執行功能的時間,查詢和請求數,並給我一些關於這方面的數據?比如像Ruby on Rails logger衡量查詢和執行功能的性能

如果存在,請問如何使用它?

在Ruby中,當我這樣的:

class ArticlesController < ApplicationController 
    # ... 

    def create 
    @article = Article.new(params[:article]) 
    logger.debug "New article: #{@article.attributes.inspect}" 
    logger.debug "Article should be valid: #{@article.valid?}" 

    if @article.save 
     flash[:notice] = 'Article was successfully created.' 
     logger.debug "The article was saved and now the user is going to be redirected..." 
     redirect_to(@article) 
    else 
     render action: "new" 
    end 
    end 

    # ... 
end 

,並讓這樣的:

Processing ArticlesController#create (for 127.0.0.1 at 2008-09-08 11:52:54) [POST] 
    Session ID: BAh7BzoMY3NyZl9pZCIlMDY5MWU1M2I1ZDRjODBlMzkyMWI1OTg2NWQyNzViZjYiCmZsYXNoSUM6J0FjdGl 
vbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA=--b18cd92fba90eacf8137e5f6b3b06c4d724596a4 
    Parameters: {"commit"=>"Create", "article"=>{"title"=>"Debugging Rails", 
"body"=>"I'm learning how to print in logs!!!", "published"=>"0"}, 
"authenticity_token"=>"2059c1286e93402e389127b1153204e0d1e275dd", "action"=>"create", "controller"=>"articles"} 
New article: {"updated_at"=>nil, "title"=>"Debugging Rails", "body"=>"I'm learning how to print in logs!!!", 
"published"=>false, "created_at"=>nil} 
Article should be valid: true 
    Article Create (0.000443) INSERT INTO "articles" ("updated_at", "title", "body", "published", 
"created_at") VALUES('2008-09-08 14:52:54', 'Debugging Rails', 
'I''m learning how to print in logs!!!', 'f', '2008-09-08 14:52:54') 
The article was saved and now the user is going to be redirected... 
Redirected to # Article:0x20af760> 
Completed in 0.01224 (81 reqs/sec) | DB: 0.00044 (3%) | 302 Found [http://localhost/articles] 

謝謝你的任何答覆。

回答

0

如果您安裝了xdebug,那麼您可以使用以下功能。

xdebug_start_trace('/path/to/trace/file.log'); 
xdebug_stop_trace();