Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!udel!mmdf From: Dennis_Grant@cmr001.bitnet Newsgroups: comp.sys.amiga.programmer Subject: NorthC and BYTE sieve demo Message-ID: <45620@nigel.ee.udel.edu> Date: 23 Feb 91 23:57:54 GMT Sender: mmdf@ee.udel.edu Lines: 37 I needed a first program for my new copy of NorthC, and I happened to have an old BYTE magazine lying around, the issue where they introduced their new benchmark suite. Inside was the source code for the sieve program (the one that finds prime numbers). I typed it in, less the 2 lines that dealt with getting system time values (I'd save those for later) and ran the program. For those who may not be familliar with the program, it finds all the prime numbers up to 16000 or so, 100 times over. In the version in the magazine, it printed out each prime as it was found, so you wound up with a LONG list of about 1600000 numbers. On a PC-XT, it (supposedly) took about 250 seconds. So anyway, off it goes, printing numbers. 5 minutes go by, and I start to get suspicious. So I rebooted the machine, checked my code vs the code in the magazine (it was right), and added a printf to print out what loop it was on. I ran this one, and went to bed. (It was 03:00) I got up at 10:30, turned on the monitor, and lo! It hadn't finished. I waited for the numbers to wrap over so I could see how far it got, and I found it was on loop 57. The machine got the 3 finger salute. I edited the source code, got rid of the printf("%d\n",prime); statement inside the main loop, and reran it. Bingo! One loop each second. (More or less) for a final score of about 100 or so. As expected. My conclusion: The printf was taking a LOT of time to execute. My question: Is this normal? Could a lowly XT really crank out 1600000 printfs faster than my Amiga, or is this a quirk of NorthC? (or did BYTE delete those printfs too?) Any ideas? ------------------------------------------------------------------------------- Dennis Grant 3rd year CS student at Le College Militaire Royal de St-Jean DETUD595@CMR001.BITNET How much do I love thee? My accumulator overflows!