Solved

Console output slowdown on Core Duo system versus P4 system

Posted on 2006-10-27
6
235 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

717 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