___
recent
archive
home
About Us
VGGTV
Contact Us

___
___
|-  -|

Let1kWindowsBloom


By Rob Terrell

Here's a program I wrote that time how long it takes to open and close 1,000 windows. Download the Carbon application here for use on Mac OS X or Mac OS 9.1 or the PowerPC-only application for use on Mac OS 9.1 or under the Classic environment.

You can see some users' results here. Please DO NOT email your results to me any more. I've been innundated with results, flames, and spam thanks to this silly little app.

It's been pointed out that, since Mac OS X provides double-buffered windows, this app really only shows the differences between creating non- and double-buffered windows...which is substantial. People much smarter than me have gone to great length to show what an idiot I was to write this app. (Feel free to search the usual Mac forums if you'd like to see people call me names.)

Anyway, I stand by the fact that, in a day of using my computer, I'll probably open a couple hundred of windows, and thus I spend a good deal of time just waiting for the OS to draw them.

The fact that people continue to download and run this app shows me that (a) we need a decent comprehensive benchmarking app for OS X, and (b) people continue to wish their Mac was faster.



The source code:
/*
 * Creates and destroys 1000 windows using Carbon or Classic
 *
 * By Rob Terrell 
 * http://www.vgg.com/rob/
 * 
 */

#include <Dialogs.h>
#include <Fonts.h>
#include <MacWindows.h>
#include <Menus.h>
#include <QuickDraw.h>
#include <TextEdit.h>

#include <Timer.h>
#include <stdio.h>
#include <sioux.h>

static void Initialize(void)
{
#if !TARGET_API_MAC_CARBON
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
#endif
	InitCursor();
}

void main(void)
{
	int c;
	WindowPtr w;
	Rect r;
	UnsignedWide start, end;
	long elapsed;
	
	Initialize();
	SetRect(&r, 100,100, 500, 300);
	
	Microseconds(&start);
	
	for (c=0; c<1000; c++) {
		w = NewWindow(nil, &r, "\pWindowTest", true, 0, (WindowRef)-1L, false, 0L);
		if (w!=nil) DisposeWindow(w);		
	}
	Microseconds(&end);
	
	elapsed = end.lo - start.lo;
	SIOUXSettings.asktosaveonclose = false;
	printf("Total time to create and dispose %i windows: %d seconds
	(%i microseconds) ", c, elapsed / 1000000, elapsed);
	
}



This page has been viewed times since I added a counter.
|_
_|

© copyright 2001 The Van Gogh-Goghs