( Index )
Month

Brief Information about the June '03 CSIG Meeting

Miscellaneous Topics and Yearly Review

B. Arnold

Samples

The subject for this month is a potpourri of topics and a review of the topics discussed this past year. Most topics will refer to Visual C++ version 6.0.

Additionally, we will discuss some functions which may be used for bench-marking programs or parts of programs.

Sample Code

// Sample.cpp           B.Arnold    6/14/03
//
//  Object:  to benchmark using the Windows 2000 performance counter
//
#include "stdafx.h"
#include "stdio.h"
#include "windows.h"


class CSummation 
    {
    public:
        CSummation () : sum_ (0) {}
        void sum (int value) { sum_ += value; }
        int value () const { return sum_; }
    private:
        int sum_;
    };


int main(int argc, char* argv[])
    {
    LARGE_INTEGER freq, count1, count2;
    LONGLONG freq64, count1_64, count2_64, microsecs;
    int i;
    CSummation test;
    CSummation * sp = &test;

    QueryPerformanceFrequency(&freq);
    freq64 = freq.QuadPart;
    QueryPerformanceCounter(&count1);
    count1_64 = count1.QuadPart;

    for (i=0; i<1000000; i++)
        sp->sum (i);

    QueryPerformanceCounter(&count2);
    count2_64 = count2.QuadPart;
    microsecs = (count2_64 - count1_64) * 1000000;
    microsecs /= freq64;
    printf("i=%d sum=%d time(microsecs)=%I64d\n",i,sp->value(), microsecs);
    return 0;
    }

"Random Access" questions start at 7:30 Tuesday night.

SOURCE CODE

Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page