Solved

Console output slowdown on Core Duo system versus P4 system

Posted on 2006-10-27
6
222 Views
Last Modified: 2010-04-01
Hi everyone, I have a simple application as written below:

#include <Windows.h> //For Windows API usage
#include <conio.h> //For making the console to stay up after it finishes

int main(int argc, char* argv[]) {
    COORD plotcoord;
    CHAR runChar = '*';
    HANDLE oHandle = GetStdHandle(STD_OUTPUT_HANDLE);
    DWORD cWritten;
    plotcoord.X = 0;

    for (int j= 0; j< 25; j++){
    plotcoord.Y = j;
    for (int i= 0; i< 80; i++){
        runChar = (char) i;
        plotcoord.X = i;
        Sleep(1);
        WriteConsoleOutputCharacter(oHandle, &runChar, 1, plotcoord, &cWritten);
    }
    }
   
    //Press any key to exit, process finishes
    getch();

    //Exit
    return 0;
}


The program runs noticably slower on my Laptop with a Core Duo 2.0Ghz CPU and 1GB RAM compared with my desktop with a P4 2.0Ghz with 1GB RAM.
By slower, I am the speed at which the letters are displayed onto the console.

I am not sure if this is a hardware dependent issue or if I mess up some settings on my laptop OS?
Is there anything that can affect how long the "sleep" command actually sleep for?

Also, FYI, I am using Bloodshed Dev-C++ to compile the file, I am not sure either if I set up anything that could have cause the slowdown.
I tried uninstalling and reinstallng Bloodshed, it still doesnt help.
Also, when comparing the speed, I basically just carry over the exe file and run it on the other system.

Any help will be grealy appreciated.
0
Comment
Question by:ronli_84
  • 3
6 Comments
 
LVL 8

Expert Comment

by:deepu chandran
Comment Utility
Hi,

There is nothing wrong with your hardware.You have given one millisecond Delay using
Sleep() Function.
You just check after comment that line and run it.It will work very faster.

Deepu
0
 

Author Comment

by:ronli_84
Comment Utility
I do agree that it works very fast without the comment line.

But my question was why is there a significant difference in the effect of the sleep command from the two machines.
Could the environment affect it? or hardware affecting.
0
 

Author Comment

by:ronli_84
Comment Utility
anyone know??
0
 

Author Comment

by:ronli_84
Comment Utility
It looks like it is related to sleep state of the CPU.
The program seems fine by plugging in the AC adapter and forcing full CPU utilization.

Please close the question. Thank you
0
 
LVL 1

Accepted Solution

by:
kodiakbear earned 0 total points
Comment Utility
Closed, 300 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maze travler 6 47
C++ assignment question 7 127
TCP/IP Socket - connection close results in data lost 14 110
C++ mouse_event mouse look 7 20
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now