Solved

VB.Net Measure time it takes to execute MySQL Command

Posted on 2011-02-27
5
647 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
  • 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

807 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