TweetFollow Us on Twitter

Sep 90 Letters
Volume Number:6
Issue Number:9
Column Tag:Letters

A Call For Benchmarks

By Kirk Chase, Editor, MacTutor

Mouser Info Needed

David Landowne

Miami, FL

Help! I’ve been reading MacTutor for four years, great mag, but today I’m trying to track down a hot tip from the April 90 issue. In your Letter column, Greg Poole talks about the Mouser 1.2d5 and says it is available on AppleLink in the MacApp discussion folder. Soo I go to my local Link and in 20 minutes cannot find a MacApp folder or Mouser or anything with 1.2d5 in the software library. My host gets bored and says he’ll try later.

Do you have any further info or can you contact Greg Poole for me and find this browsing tool. It sounds like just what I need at my point in the learning curve.

While I have the line open, an answer to Mike Scanlin is

andi #0x8007
bpl  @1
ori  #0xFFF8
@1

Thanks and thanks for having such a great MacTutor.

[Mouser is now included in MacApp 2.0 which is available from APDA and on AppleLink, Developer Services:Macintosh Development Tool Discussions: MacApp Discussion:Mouser.-ed]

Benchmark Challenge

Walt Davis, Steve Bayer

Webster, TX

If you ask experienced programmers which language, C or Pascal, produces a faster implementation of a given algorithm on a given machine, we’d bet at least 9 out of 10 would choose C. Experienced programmers know C is closer to the native machine language, provides register variables, and is more flexible than Pascal. After all, wasn’t Unix written in C? Besides, Pascal is perceived as a higher-level language than C used mostly for teaching. Aren’t higher-level languages generally slower?

Imagine our surprise when we ran some simple comparison tests using Symantec’s THINK C 4.0 and THINK Pascal 2.0 compilers for the Mac. It all started over a discussion about the comparative performance of Case (Switch in C) and the If-Then_Else language constructs. Since we expected Case (or Switch) to be a specialized form of the If-Then-Else, we expected Case to be quicker and for the most part our results showed this to be true for both C and Pascal compilers. The code we used for our tests is summarized below:

{1}

Pascal

{If-Then-Else Test Procedure }
procedure TestIfThenElse;
var
 i, startT, stopT: longint;
 b: integer;
begin
 GetDateTime(startT);
 for i:= 1 to 1000000 do
 begin
 if b = 1 then
 begin
 end
 else if b = 2 then
 begin
 end
  
 else if b = 15 then
 begin
 end;
 end;
 GetDateTime(stopT);
 ShowElapsedTime(startT, stopT);
end;

{ Case Test Procedure }
procedure TestCase;
var
 b: integer;
 i, startT, stopT: longint;
begin
 GetDateTime(startT);
 for i := 1 to 1000000 do
 begin
 case b of
 1:
 begin
 end;
 2:
 begin
 end;
  
 15:
 begin
 end;
 otherwise
 end;
 end;
 GetDateTime(stopT);
 ShowElapsedTime(startT, stopT);
end;

/* 2 */

C

/* If-Then-Else Test Function */
TestIfThenElse() {
int b;
long i, startT, stopT;

GetDateTime(&startT)
for (i = 0; i < 1000000; i++) {
 if (b==1) {} else
 if (b==2) {} else
  
 if (b==15) {};
}
GetDateTime(&stopT);
ShowElapsedTime(startT, stopT);
}

/* Switch Test Procedure */
TestSwitch() {
int b;
long i, startT, stopT;

GetDateTime(&startT);
for (i = 0; i < 1000000; i++) {
 switch (b) {
 case (1):
 break;
 case (2):
 break;
  
 case (15):
 break;
 }
}
GetDateTime(&stopT);
ShowElapsedTime(startT, stopT);
}

The If-Then and Case/Switch constructs in the test procedures and functions compare the variable b with integer values from 1 through 15. We measured the time it took to complete one million loops for values of b ranging from 1 to 20. There were no Mac Toolbox calls within the loops so no conversion from C to Pascal was required, and we compiled all code with the math coprocessor option disabled. We ran identical tests on the Mac Plus, Mac SE, and Mac II models under Finder, not MultiFinder. Table 1 shows our results in tabular form and Figure 1 shows a chart of the results for the Mac Plus Tests.

Table 1. Time (seconds) To Execute If-Then-Else versus Case/Switch Procedures

Figure 1. Test Results For If-Then-Else versus Switch/Case on a Mac Plus

Our tests show a similar relationship between the If-Then-Else and Case constructs in Pascal and the If-Then-Else and Switch constructs in C. The surprising results of our tests is that, depending on the machine, it can take anywhere from 60% to over 100% longer to execute a particular language construct in C than it does in Pascal. These results really just point out the obvious; that the relative speed of a high-level language depends on the assembly language produced by the compiler and not the high-level language itself.

In closing, we would like to challenge MacTutor and its readers to repeat these tests using the Symantec compilers on similar hardware platforms to verify our results. Do these results hold for other compilers, e.g. MPW? How do other languages like Fortran and Modula-2 compare? Do these results hold for other language constructs besides the ones tested here?

SANE Bypass Help Needed

Martin E. Huber

Boulder, CO

I am a scientific/technical researcher and use the Macintosh for lengthy numerical simulations of physical systems. I would like to get every bit of speed I can out of the floating-point co-processor (FPU) and am not sure my current compiler uses it to its full potential. The accuracy provided by the 68881/68882 chips is more than sufficient for my needs the SANE standards are over-kill.

I have heard somewhere (I don’t remember where) that there are a few different ways programs on the Mac execute floating point operations. First, the FPU can be ignored altogether, in which case SANE uses the CPU for all operations. Second, if a FPU is present, SANE routines are used, but the routines use the FPU. Finally, the floating point operations can bypass SANE altogether and be passed directly to the FPU. Is this description accurate?

If so, I would like to find a compiler which bypasses SANE for ALL arithmetic functions (including add/subtract, multiply/divide), not just for the transcendental functions. Does such a beast exist? (I’ve heard that some compilers which make “direct” FPU calls still end up running through SANE.) Can you tell me which compiler provides the fastest running number-crunching code on a Mac with a FPU (in each of the languages Fortran, Pascal, Basic, and C, if possible), or at least where I might find such information? I haven’t seen any compilation of benchmark results lately. Thanks for any assistance you can provide.

Metrowerks Modula-2

Greg Galanos

Metrowerks, Inc.

The Trimex Bldg, Rte 11

Mooers, NY, 12958.

I would like to respond to Allen Stenger’s letter, which appeared in the July issue of MacTutor, by clarifying a certain number of technical points brought up with respect to the Metrowerks Modula-2 Professional Standalone Edition compiler. Before starting I would like to thank Allen for his perceptive comments.

The peculiar-looking code that Allen refers to, implemented through a jump table, is uniquely the runtime support necessary to implement functions not supported by the 68000 processor. All normal procedures are called in the usual method used on the Motorola processor family. (I will come back to this issue during the discussion on dynamic linking). Metrowerks Modula-2 PSE generates native 68000 (or 68020/030) code, the above being one of only two instances where jump tables are used. The second instance is in the treatment of CASE statements and this is due to change in a subsequent releases this year.

Allen is correct in stating that the debugger does not like anchored variables. The main reason is that when we upgraded the PSE compiler to correctly handle AVs to provide source-code compatibility with the MPW compiler, we forgot to upgrade the debugger to handle their display. However this will be fixed in the next release, due around the same time as this issue will appear.

A point of clarification on the rumored TML Modula-2 compiler, which was written by Bob Campbell and licensed to TML Systems for publishing. Unfortunately for reasons unknown, but certainly not because of the quality of the Campbell compiler, TML decided to withdraw the compiler from the marketplace and thus lost the distribution rights to the product.

Metrowerks decided that the Campbell compiler was an extremely well written MPW compiler and entered into a joint development and publishing agreement with Mr. Campbell last November. Since then, and until market introduction in April 1990, the developers have been working on bringing both the PSE and MPW compilers up to source-code compatibility (while the anchored variable display in the debugger went unnoticed).

On compiler speed, Allen mentioned that the PSE compiler is half as fast as the Sempersoft compiler. We have not been able to find the mentioned compiler on the market but this is an unfair comparison. The PSE compiler may take more time during the symbol file importation but this is due to the fact that we are giving the user a graphical progress report of the compilation pass and this certainly slows down imports because of the screen updating. This is not the case for an MPW tool.

We did however check compile times between the Modula-2 MPW Edition, MPW Pascal and MPW C and the following table displays the hand-checked results of compiling the TubeTest example program distributed with MPW by MacDTS.

MPW Edition MPW Pascal MPW C

6 6 11

(in seconds on a Mac-IIci, MPW 3.1, compiler versions 3.1)

These results lead us to believe that the Metrowerks compilers hold their own on compile speed when comparing apples with apples (no pun intended).

Dynamic Linking Explained

Now for the lengthiest part of this letter, clarifying bulky code. If anyone would care to examine an .obm file containing the object code produced by the PSE compiler, I’m sure they will notice that the code produced is short and sweet. The method used to produce a fast prototyping system in our case is called dynamic link-loading. This does not reduce compile time, but radically cuts link time through the use of dynamic links.

We use a program stack while your program is executing within the Metrowerks environment. The object files generated by the compiler are completely relocatable and need not be patched. They are merely ready to be loaded. Besides the main module, which is called to be executed at the highest level of the program stack, all modules that are directly or indirectly imported by the main program are loaded and linked with one important exception which is in the case of memory-resident modules.

A large percentage of the imported modules are already part of the resident Metrowerks shell. For instance FileIO and QuickDraw or any number of toolbox and OS managers are being used by the shell to implement the multi-window text editor, or the compiler parser/scanner. In the case where one of these modules is directly or indirectly imported by the main program the linker/loader sets up a dynamic link to the memory-resident module instead of reloading it from disk.

This permits high speed dynamic linking which provides fast compile, debug and execute cycles within the environment. When the main program completes execution, it is removed from memory along with the other imported modules that are not memory-resident. The actual implementation of the program stack is simply the following:

PROCEDURE Call (module: ARRAY OF CHAR;
           leaveLoaded: BOOLEAN; VAR   status: Status);

PROCEDURE ExecuteObmFile(name: ARRAY OF CHAR;
                         enterDebug: BOOLEAN);
VAR
  status :    Status;
BEGIN
...
  Call(name, FALSE, status);
 ...
END ExecuteObmFile;

The advantage of dynamic linking is fast turnaround time as well as the fact that your own finished application can also implement this scheme. The System.Call mechanism can be used by any program compiled with the PSE compiler. The advantage of a program stack call is that the stack is not limited to 32k segments. It may be as large as the memory available as long as the data and code size of an individual module either imported or importing is not larger than 32k each.

The tradeoff on dynamic linking is that because the nature of the link is dynamic we cannot, at this time, remove unused code (sometimes referred to as dead code) from the linked application without removing the System.Call facility. It is precisely this tradeoff that makes the produced application, and not the generated object code, larger than for instance an MPW produced application. We are currently investigating whether we will write an incremental linker or wait until Apple comes up with one.

However, this does not mean that Metrowerks Modula-2 PSE is not suitable for applications development, the proof of the pudding being that the entire Metrowerks Modula-2 Professional Standalone Edition bootstraps itself and is linked by PSE under the above mentioned dynamic linking scheme.

For those of you who do want the fast-prototyping capabilities of PSE but also want the linking capabilities of MPW, we suggest prototyping on PSE and delivering the final product on the Metrowerks MPW Edition compiler. These can be purchased separately or as a bundle for less than $300. Source-code compatibility between the two compilers gives anyone a reasonably priced solution to having the best of both worlds.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »
Embark into the frozen tundra of certain...
Chucklefish, developers of hit action-adventure sandbox game Starbound and owner of one of the cutest logos in gaming, has released their roguelike deck-builder Wildfrost. Created alongside developers Gaziter and Deadpan Games, Wildfrost will... | Read more »
MoreFun Studios has announced Season 4,...
Tension has escalated in the ever-volatile world of Arena Breakout, as your old pal Randall Fisher and bosses Fred and Perrero continue to lob insults and explosives at each other, bringing us to a new phase of warfare. Season 4, Into The Fog of... | Read more »

Price Scanner via MacPrices.net

New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more
Boost Mobile will sell you an iPhone 11 for $...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering an iPhone 11 for $149.99 when purchased with their $40 Unlimited service plan (12GB of premium data). No trade-in is required... Read more
Free iPhone 15 plus Unlimited service for $60...
Boost Infinite, part of MVNO Boost Mobile using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 15 for $60 per month including their Unlimited service plan (30GB of premium data).... Read more
$300 off any new iPhone with service at Red P...
Red Pocket Mobile has new Apple iPhones on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, available for $759 for 8-Core CPU/7-Core GPU/256GB models and $929 for 8-Core CPU/8-Core GPU/512GB models. Apple’s one-year warranty is... Read more
Updated Apple MacBook Price Trackers
Our Apple award-winning MacBook Price Trackers are continually updated with the latest information on prices, bundles, and availability for 16″ and 14″ MacBook Pros along with 13″ and 15″ MacBook... Read more
Every model of Apple’s 13-inch M3 MacBook Air...
Best Buy has Apple 13″ MacBook Airs with M3 CPUs in stock and on sale today for $100 off MSRP. Prices start at $999. Their prices are the lowest currently available for new 13″ M3 MacBook Airs among... Read more
Sunday Sale: Apple iPad Magic Keyboards for 1...
Walmart has Apple Magic Keyboards for 12.9″ iPad Pros, in Black, on sale for $150 off MSRP on their online store. Sale price for online orders only, in-store price may vary. Order online and choose... Read more
Apple Watch Ultra 2 now available at Apple fo...
Apple has, for the first time, begun offering Certified Refurbished Apple Watch Ultra 2 models in their online store for $679, or $120 off MSRP. Each Watch includes Apple’s standard one-year warranty... Read more

Jobs Board

DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
IT Systems Engineer ( *Apple* Platforms) - S...
IT Systems Engineer ( Apple Platforms) at SpaceX Hawthorne, CA SpaceX was founded under the belief that a future where humanity is out exploring the stars is Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.