Solved

VB.Net Measure time it takes to execute MySQL Command

Posted on 2011-02-27
5
651 Views
Last Modified: 2012-05-11
Hey,

Is there a way to measure the time it takes to measure how long it takes to execute a MySQL Command in MySQL?

Thanks!
Jessee
0
Comment
Question by:Letsgetcoding
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 3

Expert Comment

by:sergiobg57
ID: 34991922
Use a profiler:

http://technet.microsoft.com/en-us/library/cc966515.aspx

Open in new window

0
 

Author Comment

by:Letsgetcoding
ID: 34991983
Hey there,

I'm sorry but I am unable to see how I would implement that. I'm still rather new to MySQL.

I'm needing to hard code whatever it is that can do this, into my VB.Net Windows Form Application.

The database is external, and I am only able to access it via PHPMyAdmin.

Jessee
0
 
LVL 3

Accepted Solution

by:
sergiobg57 earned 500 total points
ID: 34992064
A profiler can be used in remote DBs as well.

A profiler is not a code, it's just a software which you start up and then run your code normally.
The profiler then will record each access to the database that your code does and will tell how many time it took for the query to get fully executed and alot of other statistics.

When you start the profiler up, it asks you the server name and etc.

If you don't want to use a profiler, then you can use a brenchmark.
If you are not willing to spend some money in some proprietary software to do this.
Then you can simply use GetTickCount() to do the trick.

You use it before and after the execution and the subtract one by another to see how many time it took to execute that branch.


bfore = GetTickCount();
//branch of code goes here
after = GetTickCount();

Execution_time = after - before;//miliseconds

Open in new window

0
 
LVL 3

Expert Comment

by:sergiobg57
ID: 34992072
Forgot to mention, remember that GetTickCount is an API.

So you have to import it:
Private Declare Function GetTickCount Lib "kernel32" () As Long

Open in new window


Refer to this post if you have anydoubt:
http://www.vbforums.com/showthread.php?t=231183

Open in new window

0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 34992077
Hi Letsgetcoding;

To find out how long it takes between the time you execute the query in your program until you get the results back you can implement this code.

Dim queryExecuteTime As New Stopwatch()

queryExecuteTime.Reset()
queryExecuteTime.Start()

' Place the single line of code that executes the MySQL query here

queryExecuteTime.Stop()

MessageBox.Show(queryExecuteTime.ElapsedMilliseconds & " milliseconds")

Open in new window


Fernando
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question