Laravel 4对我的查询进行了基准测试

时间:2013-12-29 01:52:54

标签: php laravel laravel-4

看起来Profiler不再使用Laravel 4了 了解函数执行的所有查询执行时间的最佳方法是什么?

我想比较两个相同功能的不同代码,看看哪种方法更快。

Eloquent VS Query Builder。

2 个答案:

答案 0 :(得分:3)

Laravel 4周围有一些分析器,这是一个:https://github.com/loic-sharma/profiler

以下是您将如何使用它:

Route::get('test', function()
{

    Profiler::startTimer('testLogging');
    $data = User::all();
    Profiler::endTimer('testLogging');

    Profiler::startTimer('testLogging');
    $data = DB::table('users')->get();
    Profiler::endTimer('testLogging');

});

这是另一个不错的选择:https://github.com/barryvdh/laravel-debugbar。看起来像旧的Laravel 3分析器。

答案 1 :(得分:3)

我使用“Clockwork”。正如Github说的那样:
Clockwork是用于PHP开发的Chrome扩展,通过新面板扩展开发人员工具,提供用于调试和分析PHP应用程序的各种信息,包括有关请求,标题,获取和发布数据,cookie,会话数据,数据库查询的信息,路由,应用程序运行时的可视化等。

看看它,太棒了! :)

相关问题