Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB.Net Measure time it takes to execute MySQL Command

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 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