home *** CD-ROM | disk | FTP | other *** search
- 18-Jun-88 14:27:31-MDT,8857;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:27:19 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22174; Sat, 18 Jun 88 14:27:18 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24560; Sat, 18 Jun 88 14:27:15 MDT
- Date: Sat, 18 Jun 88 14:27:15 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182027.AA24560@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: DiskTimer.c
-
- /* DiskTimer.c Steve Brecher
- *
- * This is an MPW C source file. Set Tabs to 4.
- *
- * This program does a performance test on the volume from which it is launched:
- * Data transfer speed:
- * 32KB reads
- * 32KB writes
- * Access time:
- * 1 512-byte read from block 0 followed by 1 512-byte read
- * from offset 1MB (volume must be at least 1MB+512bytes large)
- *
- * Each test is performed multiple times.
- *
- * The write tests use the data that was previously read, so the test is
- * non-destructive.
- *
- * The predecessor program, DiskBench, did the I/O starting at volume offset 0.
- * That was unfair if the volume started within 32KB of a cylinder boundary, or
- * if the first 32KB happened to contain a remapped block or track, or required
- * controller or driver retries due to a soft error. DiskTimer does a
- * pre-calibration by doing a smaller number of I/O iterations at various
- * offsets up to 32KB from the start of the volume, and using the offset which
- * results in the best time for the reported tests.
- *
- * To a avoid constant sector skew between I/Os, which might be unfair
- * to some drives, there is now a varying delay between I/O requests. The
- * delay is obtained via a pseudo-random number generator, using the same
- * seed on each run.
- *
- * In order to avoid confusion with results from the previous DiskBench
- * program, DiskTimer reports results in seconds instead of ticks.
- */
-
- /* #define Version "1.0" /* 15-Sep-86 */
- #define Version "1.1" /* 16-Sep-86 report results in seconds */
-
- #include <Types.h>
- #include <Strings.h>
- #include <Resources.h>
- #include <Quickdraw.h>
- #include <Fonts.h>
- #include <Windows.h>
- #include <TextEdit.h>
- #include <Dialogs.h>
- #include <Memory.h>
- #include <Events.h>
- #include <Files.h>
- #include <SegLoad.h>
-
- /* If the following two counts are changed, DITL 129 must be changed also */
- #define TransferCount 100 /* number of times to perform data transfer tes/
- #define SeekCount 80 /* number of times to perform seek test/
-
- #define CalibCount 10 /* number of read iterations for calibr/
- #define XferSize (32*1024)
- #define WaitDlogID 128
- #define ResultsAlertID 129
- #define ErrorAlertID 130
- #define GreetAlertID 131
- #define StrVolTooSmall 128
-
- #define CurApRefNum ((short *)0x900)
- #define FCBsPtr ((Ptr *)0x34E)
- #define Ticks ((longword *)0x16A)
- #define fcbVPtr 20
-
- typedef unsigned long longword;
-
- DialogPtr DlogPtr;
- Handle BuffHndl; /* to I/O buffer */
- IOParam ioPB;
- longword XferRdTicks, XferWtTicks, AccessTicks;
- Boolean SkipAccess; /* flag to skip access tests if volume too smal/
- longword VolOffset;
-
- void Error(err)
- OSErr err;
- {
- char ErrStr[8];
-
- DisposDialog(DlogPtr);
- sprintf(ErrStr, "%d", err);
- ParamText(ErrStr, 0, 0, 0);
- StopAlert(ErrorAlertID, 0);
- ExitToShell();
- }
-
- /*
- * Put up intro alert; return true/false for OK/Cancel. If OK, put up
- * "Please wait" dialog and get mouse location; get data buffer.
- * Note: random seed is initted to 1 by InitGraf.
- */
- Boolean Initialize()
- {
- extern struct qd qd;
-
- InitGraf(&qd.thePort); InitFonts(); InitWindows(); TEInit(); InitDialogs(0);
- FlushEvents(everyEvent, 0);
-
- BuffHndl = NewHandle(XferSize);
- InitCursor();
- if (Alert(GreetAlertID, 0L) == ok) {
- DlogPtr = GetNewDialog(WaitDlogID, 0, (WindowPtr)-1);
- BeginUpdate(DlogPtr);
- DrawDialog(DlogPtr);
- EndUpdate(DlogPtr);
- return true; }
- return false;
- }
-
- longword XferTest(Count, Write)
- int Count;
- Boolean Write;
- {
- int i;
- OSErr err;
- longword StartTicks, TempTicks, CurrTicks;
-
- StartTicks = *Ticks;
- for (i=0; i<Count; ) {
- ioPB.ioPosOffset = VolOffset;
- if (Write)
- err = PBWrite(&ioPB, false);
- else
- err = PBRead(&ioPB, false);
- if (err)
- Error(err);
- if (++i < Count) {
- TempTicks = *Ticks;
- Delay((Random()&7)+1, &CurrTicks);
- StartTicks += CurrTicks - TempTicks; } }
- return *Ticks - StartTicks;
- }
-
- /*
- * Set up ioPB with driver refNum and default volume's drive number.
- * Set value of SkipAccess flag.
- * Determine which offset in the set 0,4K,8K,...32K from start of volume
- * results in best 32K read time.
- */
- void Calibrate()
- {
- VCB *vcbPtr;
- longword TempTicks, BestTicks, BestOffset;
-
- vcbPtr = *(VCB **)(*FCBsPtr + *CurApRefNum + fcbVPtr);
- ioPB.ioRefNum = vcbPtr->vcbDRefNum;
- ioPB.ioVRefNum = vcbPtr->vcbDrvNum;
- ioPB.ioBuffer = *BuffHndl;
- ioPB.ioPosMode = fsFromStart;
- ioPB.ioReqCount = 512;
- VolOffset = 0;
- XferTest(1, false); /* seek to start of volume */
- ioPB.ioReqCount = XferSize;
- BestTicks = 0xFFFFFFFF;
- for (VolOffset=0; VolOffset<XferSize; VolOffset+=4096)
- if ((TempTicks=XferTest(CalibCount, false)) < BestTicks) {
- BestTicks = TempTicks;
- BestOffset = VolOffset; }
- VolOffset = BestOffset;
- SkipAccess = (vcbPtr->vcbAlBlkSiz * vcbPtr->vcbNmAlBlks) < VolOffset + ;
- }
-
- longword AccessTest()
- {
- int i;
- OSErr err;
- longword StartTicks, TempTicks, CurrTicks;
-
- ioPB.ioReqCount = 512;
- StartTicks = *Ticks;
- for (i=0; i<SeekCount/2; ) {
- ioPB.ioPosOffset = VolOffset + 1024*1024;
- if (err = PBRead(&ioPB, false))
- Error(err);
- TempTicks = *Ticks;
- Delay((Random()&7)+1, &CurrTicks);
- StartTicks += CurrTicks - TempTicks;
- ioPB.ioPosOffset = VolOffset;
- if (err = PBRead(&ioPB, false))
- Error(err);
- if (++i < SeekCount/2) {
- TempTicks = *Ticks;
- Delay((Random()&7)+1, &CurrTicks);
- StartTicks += CurrTicks - TempTicks; } }
- return *Ticks - StartTicks;
- }
-
- void Results()
- {
- char XferRdStr[8], XferWtStr[8], AccessStr[64];
- short itemHit;
-
- DisposDialog(DlogPtr); /* take down "Please wait" */
- sprintf(XferRdStr, "%6.1f", XferRdTicks/60.0);
- sprintf(XferWtStr, "%6.1f", XferWtTicks/60.0);
- if (SkipAccess)
- strcpy(AccessStr, p2cstr(*GetResource('STR ', StrVolTooSmall)));
- else
- sprintf(AccessStr, "%6.1f", AccessTicks/60.0);
- ParamText(XferRdStr, XferWtStr, AccessStr, Version);
- Alert(ResultsAlertID, 0);
- }
-
- main()
- {
-
- if (Initialize()) {
- Calibrate();
- XferRdTicks = XferTest(TransferCount, false); /* reads */
- XferWtTicks = XferTest(TransferCount, true); /* writes */
- if (!SkipAccess)
- AccessTicks = AccessTest();
- Results(); }
- ExitToShell();
- }
-
-
- Press <CR> to continue !}i
- }i
-
- [70001,1011]
- DSKTIM.C 16-Sep-86 6325 27
-
- Enter command, N for next file
- or <CR> for disposition menu !
-
- Data Library Disposition Menu
-
- 1 (REA) Read this file
- 2 (DOW) Download this file
- 3 (M) Data Library Menu
-
-
- Enter choice or <CR> for next !
-
-
- [75726,3541]
- MEMUTL 12-Sep-86 4880(2112) 106
-
- Keywords: MEMORY AVERAGE
- 18-Jun-88 14:28:43-MDT,7811;000000000000
- Return-Path: <u-lchoqu%sunset@cs.utah.edu>
- Received: from cs.utah.edu by SIMTEL20.ARPA with TCP; Sat, 18 Jun 88 14:28:31 MDT
- Received: by cs.utah.edu (5.54/utah-2.0-cs)
- id AA22192; Sat, 18 Jun 88 14:28:20 MDT
- Received: by sunset.utah.edu (5.54/utah-2.0-leaf)
- id AA24586; Sat, 18 Jun 88 14:28:17 MDT
- Date: Sat, 18 Jun 88 14:28:17 MDT
- From: u-lchoqu%sunset@cs.utah.edu (Lee Choquette)
- Message-Id: <8806182028.AA24586@sunset.utah.edu>
- To: rthum@simtel20.arpa
- Subject: EarthIdle.c
-
- #include "MenuMgr.h"
- #include "QuickDraw.h"
- #include "DialogMgr.h"
- #include "ToolBoxUtil.h"
- #include "EventMgr.h"
-
- #define appleMenuID 1
- #define fileMenuID 2
- #define WNETrapNumber 0x60
- #define UnImpTrapNumber 0x9f
- #define AppleMenuSpot 1
- #define FileMenuSpot 2
-
- /**
- ** Earth Idle [public domain]
- **
- ** This program was originally written by Michael Peirce of
- ** The Black Swamp Software Company in San Jose, California
- ** in LightSpeedC v2.13 from Think Technologies. It was a way
- ** to investigate how CPU time is divided up by MultiFinder.
- **
- ** Feel free to play around with the source code and if
- ** you get something that's either moderately interesting
- ** or a nice improvement please make it available to the
- ** various nets (or at least send me a copy!)...mrp
- **
- ** To build this program all you need is a LightSpeedC project
- ** containing this source code and the MacTraps library. You
- ** also need a resource file; you can get this by simply copying
- ** the original program and renaming it "Earth Idle.proj.rsrc" or
- ** what ever is appropriate given the name of your project file.
- **
- ** If you need (or care to) contact us, you can reach us at:
- **
- ** The Black Swamp Software Company
- ** 1680 Braddock Court
- ** San Jose, California 95125
- **
- ** or
- **
- ** "MPEIRCE" on both MCI Mail and Delphi
- **
- **
- ** Revision history...
- ** _when______ _who__________ _what________________
- ** 06-DEC-1987 Michael Peirce Initial prerelease (1.0B1)
- ** 10-DEC-1987 Michael Peirce Shows the tick count along with spinning (1.0b2)
- ** 12-DEC-1987 MIchael Peirce Now it saves the screen location across launches (1.0b3)
- ** 26-DEC-1987 Michael Peirce Readied for release (1.0)
- **/
-
- main ()
- {
- register Boolean WNEisThere,showTime = TRUE;
- register int i,lastTick;
- MenuHandle appleMenu,fileMenu;
- WindowPtr earthWindow;
- register PicHandle
- earthPict[64],
- backGround;
- EventRecord event;
- Boolean userDone = FALSE;
- WindowPtr whichWindow;
- long menuResult;
- int windowCode,theMenu,theItem,refnum,itemHit,t=0;
- register DialogPtr AboutDialog;
- Rect dragRect;
- int currentEarth = 0;
- static char name[255],istring[16];
- Point Loc;
- static unsigned long
- lastTime = 0,runningTotal = 0;
- static Rect base = {0,0,80,80};
- static Boolean onlyNulls = TRUE;
- static unsigned long
- oldTime[10] = {0,0,0,0,0,0,0,0,0,0};
- Rect **windowLocation;
-
- /*
- * Setup the standard items...
- */
-
- InitGraf(&thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(0L);
- InitCursor();
-
- lastTime = Ticks;
-
- /*
- * Setup menus
- */
-
- appleMenu = GetMenu(appleMenuID);
- fileMenu = GetMenu(fileMenuID);
- CheckItem(fileMenu,1,TRUE);
-
- AddResMenu (appleMenu, 'DRVR');
-
- InsertMenu (appleMenu, 0);
- InsertMenu (fileMenu, 0);
-
- DrawMenuBar ();
-
- /*
- * Setup our window - get it from the template.
- */
-
- earthWindow = GetNewWindow(1,0L,-1L);
-
- /*
- * Load in the Earth pictures.
- *
- * The pictures were generated using EarthPlot 3.0 with
- * latitude 30 degress north and longitude every 20 degrees.
- * The resource ID's are the degrees longitude.
- */
-
- for (i=0;i<=18;i++)
- earthPict[18-i] = GetPicture(i*20);
-
- backGround = GetPicture(-1);
-
- /*
- * Setup a drag rectangle that avoids the menu bar and leaves
- * a few pixels showing all the way around.
- */
-
- SetRect(&dragRect, 4,
- 24,
- screenBits.bounds.right - 4,
- screenBits.bounds.bottom - 4);
-
- /*
- * Draw the info text small.
- */
-
- SetPort(earthWindow);
- TextSize(9);
-
- /*
- * Is MultiFinder really out there? We really only care if
- * the WaitNextEvent trap is there to call. If it's not
- * we're probably not in MultiFinder, but we'll run any
- * way and just use GetNextEvent.
- */
-
- WNEisThere = NGetTrapAddress(WNETrapNumber,1) !=
- NGetTrapAddress(UnImpTrapNumber,1);
-
- do {
- if (WNEisThere) {
- WaitNextEvent(everyEvent,&event,0L/*WaitTime*/,0L);
- /* Note to hackers: try using different values in
- the WaitTime parameter in the above call... */
- }
- else {
- SystemTask();
- GetNextEvent(everyEvent,&event);
- }
-
- /*
- * Handle OUR events.
- */
-
- switch (event.what) {
- case updateEvt:
- BeginUpdate(earthWindow);
- DrawPicture(backGround,&earthWindow->portRect);
- EndUpdate(earthWindow);
- case mouseDown:
- windowCode = FindWindow(event.where, &whichWindow);
- switch (windowCode) {
- case inSysWindow:
- SystemClick(&event, whichWindow);
- break;
- case inMenuBar:
- menuResult = MenuSelect (event.where);
- theMenu = HiWord(menuResult);
- theItem = LoWord(menuResult);
- switch (theMenu) {
- case 0:
- break;
- case AppleMenuSpot:
- if (theItem == 1) {
- /*
- * Put up our ABOUT BOX.
- */
- AboutDialog = GetNewDialog (1,0L,(long)-1);
- ModalDialog(0L, &itemHit);
- DisposDialog(AboutDialog);
- AboutDialog = GetNewDialog (2,0L,(long)-1);
- ModalDialog(0L, &itemHit);
- DisposDialog(AboutDialog);
- }
- else {
- /*
- * Handle DA's.
- */
- GetItem(appleMenu, theItem, name);
- refnum = OpenDeskAcc (name);
- SetPort(earthWindow);
- }
- break;
- case FileMenuSpot:
- /*
- * Toggle showTime or quit
- */
- switch (theItem) {
- case 1: /* SHOWTIME */
- if (showTime = !showTime)
- CheckItem(fileMenu,1,TRUE);
- else
- CheckItem(fileMenu,1,FALSE);
- break;
- case 2: /* SAVE WINDOW POSITION */
- /*
- * Save our current window location. So figure
- * out where we are, then stuff it back into the
- * window template resource. **** WE SHOULD
- * MAKE SURE THAT IT'S ON THE SCREEN WHEN WE
- * LOAD IT BACK IN ****
- */
- windowLocation = (Rect **)GetResource('WIND',1);
-
- **windowLocation = base;
-
- LocalToGlobal(*windowLocation);
- LocalToGlobal(&botRight(**windowLocation));
-
- ChangedResource(windowLocation);
- WriteResource(windowLocation);
- break;
- case 3:
- userDone = TRUE;
- }
- break;
- }
- HiliteMenu(0);
- break;
- case inDrag:
- DragWindow(earthWindow,event.where,&dragRect);
- }
- }
-
- if (!onlyNulls || event.what==nullEvent) {
- /*
- * Save what time it is now and update our running
- * total of ticks.
- */
-
- runningTotal = runningTotal - oldTime[t];
- oldTime[t] = Ticks - lastTime;
- lastTime = Ticks;
- runningTotal = runningTotal + oldTime[t];
-
- t = (t + 1) % 10;
-
- /*
- * Now update the screen with the new Earth picture and
- * our current running total.
- */
-
- NumToString(runningTotal,istring);
-
- DrawPicture(earthPict[currentEarth],&earthWindow->portRect);
-
- if (showTime) {
- MoveTo(2,79);
- DrawString(istring);
- }
-
- /*
- * Bump our current Earth picture to be the next one.
- */
-
- currentEarth = (currentEarth + 1) % 18;
- }
-
- } while (!userDone);
-
- }
-