Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

CLS /C slow on Win7

May
12,845
164
Has anyone else noticed that "CLS /C" is significantly slower in Win7 than in XP? For a 9999-line console screen buffer the difference here is .61 second vs. .22 second. Is this because of the new console model in Win7?
 
On Thu, 22 Sep 2011 13:13:31 -0400, rconn <> wrote:

|---Quote---
|> Has anyone else noticed that "CLS /C" is significantly slower in Win7
|> than in XP?
|---End Quote---
|Haven't noticed. All CLS /C does is call FillConsoleOutputCharacter and
|FillConsoleOutputAttribute, so any timing difference would be in the console
|API handling.

The "space" key in the middle of my Gateway2000 Anykey keyboard's 8-arrow-key
array has been programmed to "C-L-S-Enter" for about 20 years. And for about 10
years I've had "alias acls=*cls /c". I press that key a lot, usually after "a".
The difference in how fast it works (Win7 vs. XP) is striking.
 
Haven't noticed. All CLS /C does is call FillConsoleOutputCharacter and
FillConsoleOutputAttribute, so any timing difference would be in the console
API handling.

Hmmm! I dunno. As I said, it takes .61 second for an 80 x 9999 console.

I can do it with a plugin in 0:00:00.00.
 
On Fri, 23 Sep 2011 01:18:42 -0400, rconn <> wrote:

|---Quote---
|> I can do it with a plugin in 0:00:00.00.
|---End Quote---
|Doubtful, because you can't do it with a single call. (The API doesn't work
|if you try to do more than 64K.)

I remember such a limitation for some console APIs, but the docs for
FillConsoleOutputAttribute and FillConsoleOutputCharacter (VS2008/2010) don't
mention it. And it doesn't seem to be the case. The code I'm using (below,
built with VS2008) works in a 80 x 9999 buffer (and a 157 x 9999 buffer in .01
sec). In testing, I first fill up the buffer with a few "DIR /s c:\"s and check
that it has been cleared entirely (it has, on both XPSP3 and Win7SP1).

Code:
INT WINAPI FASTCLS ( WCHAR *psz )
{
	CONSOLE_SCREEN_BUFFER_INFO csbi;
	DWORD dwWritten;
	COORD cdZero = {0, 0};

	GetConsoleScreenBufferInfo(STD_OUT, &csbi);

	FillConsoleOutputAttribute(STD_OUT, csbi.wAttributes,
		csbi.dwSize.X * csbi.dwSize.Y, cdZero, &dwWritten);

	FillConsoleOutputCharacter(STD_OUT, L' ',
		csbi.dwSize.X * csbi.dwSize.Y, cdZero, &dwWritten);

	SetConsoleCursorPosition(STD_OUT, cdZero);

	return 0;
}
 
On Fri, 23 Sep 2011 01:18:43 -0400, rconn <> wrote:

|---Quote---
|> I can do it with a plugin in 0:00:00.00.
|---End Quote---
|CLS /C takes 0.10 seconds on my system with a 200 x 10,000 display.

For me it's still .61 sec with 157 x 9999. I have 4 x 2.66Ghz and a rather
pedestrian NVIDIA Quadro FX570.
 

Similar threads

Back
Top