Solved

Console output slowdown on Core Duo system versus P4 system

Posted on 2006-10-27
6
223 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
ID: 17824462
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
ID: 17824729
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
ID: 17831457
anyone know??
0
 

Author Comment

by:ronli_84
ID: 17847672
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
ID: 17877267
Closed, 300 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

863 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

23 Experts available now in Live!

Get 1:1 Help Now