Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6674985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:47:51+00:00 2026-05-26T03:47:51+00:00

My tests are running pretty slow… I’ve got under 100 tests, but it still

  • 0

My tests are running pretty slow… I’ve got under 100 tests, but it still takes over 10 seconds to run on a fast machine. I tried disabling code coverage, and using caching for the couple of things I do that hit remote servers (e.g. LDAP).

Profiling the tests while PHPUnit is running produces:

screenshot

fully 10% of the running time — which includes the time to gather info for and generate a lot of pages for code coverage — is spent in mysqli->prepare. Unfortunately, I can’t abstract the database out here. Not only am I effectively testing a database access layer itself, a lot of logic is implemented in terms of JOINs inside the code under test.

Are there any configuration settings I can change or anything of that nature to make this faster? Does prepare require calling out to the mysql server (and therefore setting up a local mysql server for testing might help?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:47:52+00:00Added an answer on May 26, 2026 at 3:47 am

    Yes, a prepare() statement will call out to the MySQL server. Prepared statements are executed server-side in two calls: a PREPARE call, and an EXECUTE call.

    Per example:

    mysql> PREPARE stmt1 FROM 'SELECT * FROM mysql.user';
    mysql> EXECUTE stmt1;
    

    Same goes for any driver, whether it is the PHP driver of a JDBC driver. To further prove that it in fact does make a call, execute this code:

    $mysqli->prepare('SELECT * FROM mysql.user');
    

    …and you can see the following in MySQL:

    mysql> show processlist;
    +-----+------+-----------+------+---------+------+-------+--------------------------+
    | Id  | User | Host      | db   | Command | Time | State | Info                     |
    +-----+------+-----------+------+---------+------+-------+--------------------------+
    | 564 | root | localhost | NULL | Query   |    0 | NULL  | show processlist         |
    | 565 | root | localhost | NULL | Prepare |    0 | NULL  | SELECT * FROM mysql.user |
    +-----+------+-----------+------+---------+------+-------+--------------------------+
    2 rows in set (0.00 sec)
    

    To accelerate this, you can use UNIX domain sockets on the local machine (assuming you have a POSIX OS). This removes the overhead of TCP handshaking and error correction, as well as network lag since it is executed locally.

    The best solution, however, is in fact to abstract your database connections using mock objects, but you already knew that. A unit test is not a unit test if it must connect to a database: it’s an integration test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm finding the feedback look pretty slow when running integration and functional tests in
I've got a slightly hackish makefile for running tests: ### Run the tests tests
I'm running Selenium tests from within Eclipse, but I can't load a custom Firefox
My applications tests are pretty hard on the database. They run create, drop and
Here are my goals: 1. Run my tests in Eclipse and see the pretty
I am attempting to run some automated tests in Eclipse using Java (running them
We have some unit tests running against a SQL server 2000 database using the
I'm struggling getting some unit tests running and wondering if anyone might have anything
For running tests on an Android app, how can I automate the tap on
I was running tests, and first time round, they all pass green. If I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.