PHP and MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jørn Dahl-Stamnes

    PHP and MySQL

    Hello,

    When doing queries from MySQL using the mysql client program, I get the time
    used to get the records at the end of the output.

    What is the best way of measuring the time used when doing a query from PHP?

    --
    Jørn Dahl-Stamnes

  • Kimmo Laine

    #2
    Re: PHP and MySQL

    "Jørn Dahl-Stamnes" <newsmanDELETE@ REMOVEdahl-stamnes.netwrot e in message
    news:44fc09b5@n ews.broadpark.n o...
    Hello,
    >
    When doing queries from MySQL using the mysql client program, I get the
    time
    used to get the records at the end of the output.
    >
    What is the best way of measuring the time used when doing a query from
    PHP?

    $started = microtime();
    query();
    $stopped = microtime();

    $elapsed = $started - $stopped;
    echo "query took $elapsed ms";

    --
    "Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
    http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
    spam@outolempi. net || Gedoon-S @ IRCnet || rot13(xvzzb@bhg byrzcv.arg)


    Comment

    • Jørn Dahl-Stamnes

      #3
      Re: PHP and MySQL

      Kimmo Laine wrote:
      "Jørn Dahl-Stamnes" <newsmanDELETE@ REMOVEdahl-stamnes.netwrot e in
      message news:44fc09b5@n ews.broadpark.n o...
      >Hello,
      >>
      >When doing queries from MySQL using the mysql client program, I get the
      >time
      >used to get the records at the end of the output.
      >>
      >What is the best way of measuring the time used when doing a query from
      >PHP?
      >
      >
      $started = microtime();
      query();
      $stopped = microtime();
      >
      $elapsed = $started - $stopped;
      echo "query took $elapsed ms";
      Sounds easy, but it always give me a negative number below 0 (ie -0.15...).
      The same query takes 11 seconds in the mysql client.

      I'm using php 4.9.3.

      --
      Jørn Dahl-Stamnes

      Comment

      • Jørn Dahl-Stamnes

        #4
        Re: PHP and MySQL

        Jørn Dahl-Stamnes wrote:
        Kimmo Laine wrote:
        >
        >"Jørn Dahl-Stamnes" <newsmanDELETE@ REMOVEdahl-stamnes.netwrot e in
        >message news:44fc09b5@n ews.broadpark.n o...
        >>Hello,
        >>>
        >>When doing queries from MySQL using the mysql client program, I get the
        >>time
        >>used to get the records at the end of the output.
        >>>
        >>What is the best way of measuring the time used when doing a query from
        >>PHP?
        >>
        >>
        >$started = microtime();
        >query();
        >$stopped = microtime();
        >>
        >$elapsed = $started - $stopped;
        >echo "query took $elapsed ms";
        >
        Sounds easy, but it always give me a negative number below 0 (ie
        -0.15...). The same query takes 11 seconds in the mysql client.
        >
        I'm using php 4.9.3.
        Solved it. In php 4.9.3 the results from microtime is a bit different than
        in 5.0.
        Thanks for the tip.
        --
        Jørn Dahl-Stamnes

        Comment

        Working...