“I feel the need for speed” is a memorable quote by the character Maverick in the 1986 Movie called Top Gun. We all want to have a server that executes as fast as a Mustang, not as slow as Yugo. With today’s servers being built on Virtual Machines (VM), how can you tell if your server is slow?
One way to determine server speed is to benchmark your physical laptop against the newly built virtual machine (VM). To do this test, you need to create a program that is both I/O and CPU intensive.
The trial division algorithm for calculating prime numbers is such a program. It uses a brute force method of trial division by 2 to sqrt(n), where n is the number in question. If the remainder is non zero for all divisions, the number is prime. Otherwise, the is not prime since it is a multiple of another.
I am going to break the TSQL program into two stored procedures and one table to save results.
- [tbl_primes] contains the number and the time it was found
- [is_prime] determines if a given number is prime
- [store_primes] find and save prime numbers between x and y to a table
You should run this program from a new Query window in SQL Server Management Studio (SSMS). The CPU will be actively performing the division, the hard disk will be actively storing results, and the output window will be showing the results of the trial division
A simple query against the resulting table tells you how long the process took.
Total time in seconds (1275)
DATEDIFF(s, DT.START, DT.FINISH) AS TOTAL_TIME,
RECS AS TOTAL_RECS
MIN(MY_TIME) AS START,
MAX(MY_TIME) AS FINISH,
COUNT(*) AS RECS
On my Intel Corre I5 laptop from Dell, the benchmark program found 348,513 prime numbers between 1 and 5 million in 21:15 mins.
Please check out performance monitor when running the program. My first virtual machine (VM) was not using load balancing accross CPU’s. This was seeing the in CPU performance window and fixed by enabling a setting in Hyper-V on Windows Server 2012.
To recap, many of today’s servers are virtual. Give this fact, running a benchmark program to determine performance is a good way to figure out how your server is ranked against physical hardware.