home *** CD-ROM | disk | FTP | other *** search
- /* This is a coding of the SIEVE program
- benchmark published in BYTE, Nov. 1985.
- It has been changed slightly so it can
- use the 200hz clock on the 520ST
- Both the int and register code is
- included just comment out one or the other.
- The execution times were 4.15 seconds
- for the int. version and 2.45 for the register.
- Not to brag on the 520 but these are
- really good times. The best I've seen. */
-
-
- #include "stdio.h"
- #include "define.h" /* this is true, false definition */
- #include "osbind.h" /* gemdos */
-
-
- #define SIZE 8190
- LONG save_ssp;
-
-
- char flags[SIZE + 1] = {0};
-
-
- main()
- {
- /* register i, prime, k, count, iter; */
- int i, prime, k, count, iter;
- UWORD ticks, *hz_200;
-
-
- hz_200 = 0x4bc;
- save_ssp = Super(0L);
-
-
- puts("\n\n\n\n\nPress any key to begin test...");
- getchar();
- puts("\nStarting\n");
- ticks = *hz_200;
-
-
- for(iter = 1; iter <= 10; iter++) {
- count = 0;
- for(i = 0; i <= SIZE; i++)
- flags[i] = TRUE;
- for(i = 0; i <= SIZE; i++) {
- if (flags[i]) {
- prime = i+i+3;
- for (k = i+prime; k <= SIZE; k+=prime)
- flags[k] = FALSE;
- count++;
- }
- }
- }
-
-
- ticks = *hz_200 - ticks;
- printf("ticks = %d\n",ticks);
- printf("Time = %f seconds\n",ticks * .005);
- printf("Primes = %d\n",count);
- printf("Done, press any key to continue...\n");
- getchar();
- Super(save_ssp);
-
-
- }
- əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə