?
Solved

VB.Net Measure time it takes to execute MySQL Command

Posted on 2011-02-27
5
Medium Priority
?
663 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 2000 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 64

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

850 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