Solved

VB.Net Measure time it takes to execute MySQL Command

Posted on 2011-02-27
5
641 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 62

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now