You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.
I can confirm that it does profile PDO prepared statements. It does not however profile raw SQL, which is a problem because I need to write a performance test that asserts my code does some operation in only 1 query.
Here's a test case that exposes the flaw in your code.
functiontestBjy()
{
// insert some data & select it back, so we can see queries actually ran. THis is 2 queries$this->db->query("INSERT INTO `product` (sku) value ('test')", \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
$result = $this->db->query("SELECT * FROM `product`", \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
print_r($result->toArray());
// running 2 more queries!$this->db->query("SELECT count(*) FROM `product`", \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
$this->db->query("SELECT * FROM `product`", \Zend\Db\Adapter\Adapter::QUERY_MODE_EXECUTE);
// lets ask it how many queries its seen, should be 4 :)$profiler = $this->db->getProfiler();
$queryProfiles = $profiler->getQueryProfiles();
$afterCount = count($queryProfiles);
// it says it has seen no queries :/
var_dump($afterCount); // 0// some sanity checking.
var_dump(get_class($profiler));
var_dump(get_class($this->db));
}
$ phpunit --filter=testBjy
.Array
(
[0] => Array
(
[id] => 135
[sku] => test
)
)
# here its saying theres 0 queries
int(0)
# this proves its indeed your code running.
string(32) "BjyProfiler\Db\Profiler\Profiler"
string(39) "BjyProfiler\Db\Adapter\ProfilingAdapter"
I have the following version of your code loaded: 1ca3161
Here's my profiler object, the bitwise filter is set to all types clearly:
You'll probably want to do some more testing before you add that, but it seems to count raw queries now, and its not double counting any of my other prepared queries that Zend's table gateway generates.
I can confirm that it does profile PDO prepared statements. It does not however profile raw SQL, which is a problem because I need to write a performance test that asserts my code does some operation in only 1 query.
Here's a test case that exposes the flaw in your code.
I have the following version of your code loaded: 1ca3161
Here's my profiler object, the bitwise filter is set to all types clearly:
I threw a debug statement into Query::start() -
It does not hit that line when running my above test.
The text was updated successfully, but these errors were encountered: