VB icon

CPU Benchmark

Email
Submitted on: 1/4/2015 4:27:00 AM
By: Brian W. Baugh (from psc cd)  
Level: Beginner
User Rating: By 3 Users
Compatibility: C, C++ (general)
Views: 1503
 
     This program allows the user to compare their computer (speed) with other computers who used the same program. The code is simple enough, the most complicated part is the color.

 

INCLUDE files:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
//INCLUDE files for :CPU Benchmark
//**************************************
#include <time.h>
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: CPU Benchmark
// Description:This program allows the user to compare their computer (speed) with other computers who used the same program. The code is simple enough, the most complicated part is the color.
// By: Brian W. Baugh (from psc cd)
//
// Inputs:Number of seconds the program should test the computer.
//
// Returns:Your compuuter's results, along with other computers and their results as a comparison.
//
// Assumes:I don't think MSV C++ likes color very much the way I did it, so it is not supported.
//
// Side Effects:None.
//**************************************

//If you run this program, please e-mail me (bbwebman@attbi.com)
//or ICQ me (#13403151) and tell me your type of processor
//(AMD/Pentium, and tell me your speed. I will update the code
//on planet-source-code so you will be able to compare to more
//computers. Thank you! Brian W. Baugh
//include files needed to compile
#include <time.h> //for recording the time
#include <iostream.h> //for cin and cout
#include <conio.h> //for colors
#include <stdlib.h> //for pausing the program at the end
void main()
{ 
 //variables to be used in the program 
 int timeToRun=0;
 int doubleThis=2;
 int loopcount=0;
 //set text-color to red
 textcolor(LIGHTRED);
 cprintf("FOR BEST RESULTS PLEASE DO NOT DO ");
 textcolor(LIGHTGREEN);
 cprintf("**");
 textcolor(WHITE);
 cprintf("ANYTHING");
 textcolor(LIGHTGREEN);
 cprintf("**");
 textcolor(LIGHTRED);
 cprintf(" ONCE THE TEST HAS BEGUN!");
 //have the user enter how long the program should run
 cout << "\n\nHow many seconds should the program test your computer?\n(Choose 15 to compare with other computers): ";
 cin >> timeToRun;
 //used to stop the program after a certain period of time specified by the user
 time_t goal=time(NULL) + timeToRun;
 //the actual loop for testing
 for (; time(NULL)!=goal; loopcount++)
 { 
 doubleThis*=2;
 }
 //tell the user the testing has finished
 cout << "\n\n";
 textcolor(YELLOW);
 cprintf("*");
 textcolor(LIGHTBLUE);
 cprintf("=================================================================");
 textcolor(YELLOW);
 cprintf("*");
 cout << "\n Test complete. Here are the results:\n"
 << " ------------------------------------\n";
 textcolor(CYAN);
 cprintf(" YOUR");
 cout << " computer: " << loopcount
 << " (in " << timeToRun
 << " seconds)\n\n Compare with other computers:\n";
 textcolor(MAGENTA);
 cprintf(" AMD-1.4GHZ");
 cout << " computer : 430000-460000 (in 15 seconds)\n";
 cprintf(" AMD-1.0GHZ");
 cout << " computer : 220000-250000 (in 15 seconds)\n";
 cprintf(" PENTIUM-233");
 cout << " computer: 47800"
 << " (plus or minus 10,000) in 15 seconds.\n";
 textcolor(YELLOW);
 cprintf("*");
 textcolor(LIGHTBLUE);
 cprintf("=================================================================");
 textcolor(YELLOW);
 cprintf("*");
 cout << "\n\nResults will vary depending upon how many programs you\nhave running in the background, memory free, etc.\n\n";
 //some computers normally quit when they reach the end of the program
 //this is to ensure that they at the very least, get to see the results
 system("pause");
 //quit the program
 return 0;
}


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.