-
Notifications
You must be signed in to change notification settings - Fork 36
Config query log
Bart van Hoekelen edited this page Apr 26, 2017
·
5 revisions
You can track query and query time by using the Laravel query log inside the performance tool.
// Add namespace at the top
use Performance\Config;
// Set config
Config::setQueryLog(true);
Config::setQueryLog($status, $viewType = null);
Item | Type | Accept | Default | Required |
---|---|---|---|---|
$status | bool |
true or false
|
false |
yes |
$viewType | string |
'resume' or 'full'
|
resume |
no |
Note: pay attention on the point label name.
use Performance\Performance;
use Performance\Config;
// Bootstrap class
$foo = new Foo();
class Foo
{
public function __construct()
{
// Enable query log
Config::setQueryLog(true);
// OR
// Config::setQueryLog(true, 'full');
$this->taskA();
// Finish all tasks and show test results
Performance::results();
}
public function taskA()
{
// Set point Task A
Performance::point(__FUNCTION__);
// Create user
$user = new User();
$user->name = 'User';
$user->save();
// Get users
$users = User::all();
// Update user
$user = User::where('name', 'User')->first();
$user->email = 'user@user.user';
$user->save();
// Delete all
$users = DB::table('user')->select('*')
->where('name', 'User')
->delete();
// Finish point Task A
Performance::finish();
}
}
Return to wiki home page