Thread: Computer Performance Checker

  1. #1
    Registered User shark_boy's Avatar
    Join Date
    Sep 2001

    Computer Performance Checker

    I am starting to write a program that checks a computers response time for certain functions. I don't know if I'm even on the right track with this code. Any suggestions?

    #include <iostream.h>
    #include <stdlib.h>
    #include <conio.h>
    #include <time.h>
    #include <iomanip.h>
    #include <string.h>

    class speed
    public :
    double memcheck( void );
    double diskcheck( void );
    double floatcheck( void );
    void sleep( clock_t wait);



    double speed::memcheck( void )
    clock_t start, finish;

    char arr_string[15] = "Memory Test123";
    char* ptr_str = new char;
    int i;
    double duration = 0;

    start = clock();

    for (i=10000; i > 0; i--)

    strcpy(ptr_str, arr_string);
    // delete ptr_str;
    ptr_str = NULL;


    finish = clock();
    duration = (double)(finish - start) / CLOCKS_PER_SEC;
    cout << "This test lasted " << duration << " seconds";

    return duration;

    int main()
    speed perf;

    cout << perf.memcheck();

    return 0;

    Something's fishy here.

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    In your loop you should

    - Allocate memory
    - Copy to memory
    - De-allocate memory

    in that order, so that the memory is correctly obtained and cleaned up for each iteration.

    Also you may be able to get more precise results by using a higher resolution timer, but these are system dependent.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 34
    Last Post: 02-26-2006, 01:16 PM
  2. Regarding Undergraduate Computer Majors
    By UnregdRegd in forum A Brief History of
    Replies: 11
    Last Post: 10-04-2003, 11:55 AM
  3. Better computer, worse performance
    By jdinger in forum Game Programming
    Replies: 8
    Last Post: 07-27-2003, 11:06 AM
  4. Problems shutting off computer
    By frenchfry164 in forum Tech Board
    Replies: 9
    Last Post: 04-22-2003, 06:19 PM
  5. computer sex
    By Unregistered in forum A Brief History of
    Replies: 5
    Last Post: 09-17-2001, 07:09 PM