Write a toy benchmark in C or C language Use your benchmark

Write a toy benchmark in C (or C++) language. Use your benchmark to evaluate performance at least three computers. I suggest you to compare performance using wall clock time. Remember that you need to execute your benchmark at least 10 time and then calculate arithmetic means. Then compare results of your benchmark with results obtained using some available at Internet benchmarks (you need to choose only one). How well your benchmark evaluates performance?

Solution

Dear Asker,

Benchmarking is a method to compare performance of two or more systems/process.

Here is a toy benchmark, that calculates time consumed by CPU to count upto 1 billion,

using namespace std;
#include<iostream>
#include<time.h>

int main(){
int x=0;
clock_t start,finish;

//record starting time
start=clock();
for(int i=0;i<1000000000;i++){
    x+=1;
}

//record finishing time
finish=clock();

cout<<\"Elapsed time: \"<<(finish-start)*1000.0/CLOCKS_PER_SEC<<\" ms\";
return 0;
}

How does it work? the \'clock()\' function calculates number of cpu clocks comsumed by the program so far, we call this function before and after the code we want to benchmark. And, the difference between these two numbers is number of clocks consumed by the code under test, then we divide it by number of clocks per second (which is system dependent constant) to get number of seconds.

Write a toy benchmark in C (or C++) language. Use your benchmark to evaluate performance at least three computers. I suggest you to compare performance using wa

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site