Ticket #391 (closed task: duplicate)

Opened 8 months ago

Last modified 2 weeks ago

Database profiler time

Reported by: agsel Owned by:
Priority: important Milestone: 2.0.2 Stable
Component: Database adapter Version: 1.0.0 Stable
Keywords: database, profile, timer Cc:

Description

Database profiler should use QTimer (#390) to calculate execution times of the queries.

Each query should have a start time (compared to app start time, eg how many seconds has the app been running) and execution time (the duration of the query).

Profile array should have to timer object as the 3rd element. Each different query should have a different timer (for example, queryLogger1, queryLogger2 etc).

Attachments

profiling_time.patch (4.8 kB) - added by agsel 8 months ago.

Change History

Changed 8 months ago by VexedPanda

Since we're trying to build test cases for core functionality, maybe this is a good (read simple) test case to try out Test Driven Design?

Changed 8 months ago by agsel

Changed 8 months ago by agsel

Add first draft of profiling which uses qtimer.

Things todo:

  • add logging to postgresql, sqlserver.
  • QDatabaseBase::GetLogTimerName?() currently returns only numbers. I already added 'qdatabase' in front of number (timers will be qdatabase1, qdatabase2 etc). This is ok in the next patch.

In profile.php I only show execution time. We could create a simple usage, where we add only execution time to profile array and show it out in profile.php. Current approach gives an option to use other possibilities of qtimer (for example if user customizes it).

Currently it logs time of execution. But in Query method, there is resultset initialization also. Should it be included in timing? For example, currently I have:

			// Log Query (for Profiling, if applicable)
			$this->LogQuery($strQuery);

			// Perform the Query
			$objResult = $this->objMySqli->query($strQuery);

			// Calculate query time
			$this->LogQueryTime();

			if ($this->objMySqli->error)
				throw new QMySqliDatabaseException($this->objMySqli->error, $this->objMySqli->errno, $strQuery);

But it could be:

			// Log Query (for Profiling, if applicable)
			$this->LogQuery($strQuery);

			// Perform the Query
			$objResult = $this->objMySqli->query($strQuery);

			if ($this->objMySqli->error)
				throw new QMySqliDatabaseException($this->objMySqli->error, $this->objMySqli->errno, $strQuery);

			// Return the Result
			$objMySqliDatabaseResult = new QMySqli5DatabaseResult($objResult, $this);

			// Calculate query time
			$this->LogQueryTime();
			return $objMySqliDatabaseResult;

Changed 8 months ago by VexedPanda

$fltTime isn't initialized, and may be unset when output.

I'm also unsure why you're using a plain number as the timer name. It's also possible there should be concern here with the timers conflicting with user-created timers..? It may be smart to use specific instantiations instead of named timers, or to be really obscure in the names used.

Changed 6 months ago by alex94040

  • status changed from new to in_QA
  • milestone changed from 2.0 to 1.1.2

Since QTimers are now included in 1.1.1 release, it might make sense to do this, too.

Changed 4 weeks ago by alex94040

  • milestone changed from 1.1.2 to 1.1.3

Changed 2 weeks ago by alex94040

  • status changed from in_QA to closed
  • resolution set to duplicate
  • milestone changed from 1.1.3 to 2.0.2

This has been re-implemented using QTimer + logic that's shared across all database adapters in #608.

Note: See TracTickets for help on using tickets.