code: public function replaceProfiler()
      {
          /** @var Magento_Db_Adapter_Pdo_Mysql $connection */
          $connection = Mage::getSingleton('core/resource')->getConnection('core_write');
          $currentProfile = $connection->getProfiler();
  
          if ($currentProfile) {
              // Copy queries
              $this->_queryProfiles = $currentProfile->_queryProfiles;
          }
  
          $this->setEnabled($currentProfile->getEnabled());
          $connection->setProfiler($this);
      }
docs: Responsible to copy queries from current profiler and set this instance sql profiler
  
  @throws Zend_Db_Profiler_Exception