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

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 »
Top Mobile Game Discounts
Every day, we pick out a curated list of the best mobile discounts on the App Store and post them here. This list won't be comprehensive, but it every game on it is recommended. Feel free to check out the coverage we did on them in the links below... | Read more »
Marvel Future Fight celebrates nine year...
Announced alongside an advertising image I can only assume was aimed squarely at myself with the prominent Deadpool and Odin featured on it, Netmarble has revealed their celebrations for the 9th anniversary of Marvel Future Fight. The Countdown... | Read more »
HoYoFair 2024 prepares to showcase over...
To say Genshin Impact took the world by storm when it was released would be an understatement. However, I think the most surprising part of the launch was just how much further it went than gaming. There have been concerts, art shows, massive... | Read more »
Explore some of BBCs' most iconic s...
Despite your personal opinion on the BBC at a managerial level, it is undeniable that it has overseen some fantastic British shows in the past, and now thanks to a partnership with Roblox, players will be able to interact with some of these... | Read more »

Price Scanner via MacPrices.net

You can save $300-$480 on a 14-inch M3 Pro/Ma...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
24-inch M1 iMacs available at Apple starting...
Apple has clearance M1 iMacs available in their Certified Refurbished store starting at $1049 and ranging up to $300 off original MSRP. Each iMac is in like-new condition and comes with Apple’s... Read more
Walmart continues to offer $699 13-inch M1 Ma...
Walmart continues to offer new Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBook for sale by... Read more
B&H has 13-inch M2 MacBook Airs with 16GB...
B&H Photo has 13″ MacBook Airs with M2 CPUs, 16GB of memory, and 256GB of storage in stock and on sale for $1099, $100 off Apple’s MSRP for this configuration. Free 1-2 day delivery is available... Read more
14-inch M3 MacBook Pro with 16GB of RAM avail...
Apple has the 14″ M3 MacBook Pro with 16GB of RAM and 1TB of storage, Certified Refurbished, available for $300 off MSRP. Each MacBook Pro features a new outer case, shipping is free, and an Apple 1-... Read more
Apple M2 Mac minis on sale for up to $150 off...
Amazon has Apple’s M2-powered Mac minis in stock and on sale for $100-$150 off MSRP, each including free delivery: – Mac mini M2/256GB SSD: $499, save $100 – Mac mini M2/512GB SSD: $699, save $100 –... Read more
Amazon is offering a $200 discount on 14-inch...
Amazon has 14-inch M3 MacBook Pros in stock and on sale for $200 off MSRP. Shipping is free. Note that Amazon’s stock tends to come and go: – 14″ M3 MacBook Pro (8GB RAM/512GB SSD): $1399.99, $200... Read more
Sunday Sale: 13-inch M3 MacBook Air for $999,...
Several Apple retailers have the new 13″ MacBook Air with an M3 CPU in stock and on sale today for only $999 in Midnight. These are the lowest prices currently available for new 13″ M3 MacBook Airs... Read more
Multiple Apple retailers are offering 13-inch...
Several Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices... Read more
Roundup of Verizon’s April Apple iPhone Promo...
Verizon is offering a number of iPhone deals for the month of April. Switch, and open a new of service, and you can qualify for a free iPhone 15 or heavy monthly discounts on other models: – 128GB... Read more

Jobs Board

Relationship Banker - *Apple* Valley Financ...
Relationship Banker - Apple Valley Financial Center APPLE VALLEY, Minnesota **Job Description:** At Bank of America, we are guided by a common purpose to help Read more
IN6728 Optometrist- *Apple* Valley, CA- Tar...
Date: Apr 9, 2024 Brand: Target Optical Location: Apple Valley, CA, US, 92308 **Requisition ID:** 824398 At Target Optical, we help people see and look great - and Read more
Medical Assistant - Orthopedics *Apple* Hil...
Medical Assistant - Orthopedics Apple Hill York Location: WellSpan Medical Group, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Apply Now Read more
*Apple* Systems Administrator - JAMF - Activ...
…**Public Trust/Other Required:** None **Job Family:** Systems Administration **Skills:** Apple Platforms,Computer Servers,Jamf Pro **Experience:** 3 + years of Read more
Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.