Solved

Console output slowdown on Core Duo system versus P4 system

Posted on 2006-10-27
6
227 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 learn how to clear a vector as well as how to detect empty vectors in C++.

832 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