Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- cpucalc.c - an Amiga C compiler benchmark
- measures CPU time usage for 5.000.000 looped runs
- through log(index)
- (c) Michael Bergmann 01-10-2023
- COMPILE:
- sc math=standard optimize opttime optloop noicon cpucalc.c link to cpucalc_sc
- vc +aos68k -v -c99 -lmieee -lauto -o cpucalc_vc cpucalc.c
- gcc -Wall -lm -lauto -Os -o cpucalc_gcc_ix cpucalc.c
- dcc -3.1 -vv -lm cpucalc.c -o cpucalc_dcc
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <time.h>
- #include <exec/types.h>
- #include <proto/exec.h>
- char *vers="\0$VER: cpuCalc v1.0 (01.10.2023)"; /* Version string */
- char *stacksize = "$STACK:8192"; /* only works when started from CLI */
- /* Function proto types */
- STRPTR identifyCompiler(void);
- int main(void);
- /*
- * Function: identifyCompiler()
- * Purose: Collect compiler system informations
- */
- STRPTR identifyCompiler(void)
- {
- char myCompiler[512];
- #ifdef __SASC
- const int sasversion = __VERSION__;
- const int sasrev = __REVISION__;
- #endif
- #if defined(__STORM__)
- /* Compiler is StormC3 */
- sprintf(myCompiler, "StormC3");
- #elif defined(__STORMGCC__)
- /* Compiler is StormGCC4 */
- sprintf(myCompiler, "GNU gcc, StormC4 flavour");
- #elif defined(__MAXON__)
- /* Compiler is Maxon/HiSoft C++ */
- sprintf(myCompiler, "Maxon/HiSoft C++");
- #elif defined(__GNUC__)
- /* Compiler is gcc */
- sprintf(myCompiler, "GNU gcc v%ld.%ld", __GNUC__, __GNUC_MINOR__);
- #ifdef __GNUC_PATCHLEVEL__
- strcat(myCompiler, ".");
- strcat(myCompiler, __GNUC_PATCHLEVEL__);
- #endif
- #elif defined(__VBCC__)
- /* Compiler is vbcc */
- sprintf(myCompiler, "vbcc - Volker Barthelmann's retargetable C compiler");
- #elif defined(__SASC)
- /* Compiler is SAS/C */
- sprintf(myCompiler, "SAS/C, Version %ld.%ld", sasversion, sasrev);
- #elif defined(LATTICE)
- /* Compiler is Lattice C */
- sprintf(myCompiler, "Lattice C");
- #elif defined(AZTEC_C)
- /* Compiler is Aztec C */
- sprintf(myCompiler, "Manx Aztec C v%ld", __VERSION);
- #elif defined(_DCC)
- /* Compiler is dice */
- sprintf(myCompiler, "Matt Dillon's DICE, propably v3.15");
- #else
- /* Compiler not identified */
- sprintf(myCompiler, "UNKNOWN");
- #endif
- return(myCompiler);
- }
- int main(void)
- {
- clock_t start, end; /* measure CPU time */
- double index; /* index used for log() */
- double result; /* resulting CPU consumption */
- printf("----------------------------------------------------------\n");
- printf(" ** Calculating CPU time as a C compiler benchmark ** \n");
- printf("----------------------------------------------------------\n");
- printf("Tested Compiler System: %s\n", identifyCompiler() );
- /* -- Start timer -- */
- start = clock();
- printf("\nTest START: %ld\n", start);
- /* stress routine */
- for ( index = 1.0; index <= 5000000.0; ++index )
- (void) log(index);
- /* -- Stop timer -- */
- end = clock();
- printf("Test END: %ld\n", end);
- printf("CLOCKS_PER_SEC = %d\n", CLOCKS_PER_SEC);
- printf("Elapsed: %ld\n", end - start);
- /* -- calculate time diference and print it out -- */
- result = (double) ( ((double)end - (double)start) / (double)CLOCKS_PER_SEC);
- printf("\nCPU time used: %3.3f sec.\n\n", result );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement