Beispiel #1
0
Proc0()
{
	OneToFifty		IntLoc1;
	REG OneToFifty		IntLoc2;
	OneToFifty		IntLoc3;
	REG char		CharLoc;
	REG char		CharIndex;
	Enumeration	 	EnumLoc;
	String30		String1Loc;
	String30		String2Loc;
	extern char		*malloc();

	register unsigned int	i;
#ifdef TIME
	long			time();
	long			starttime;
	long			benchtime;
	long			nulltime;

	starttime = time( (long *) 0);
	for (i = 0; i < LOOPS; ++i);
	nulltime = time( (long *) 0) - starttime; /* Computes o'head of loop */
#endif
#ifdef TIMES
	time_t			starttime;
	time_t			benchtime;
	time_t			nulltime;
	struct tms		tms;

	times(&tms); starttime = tms.tms_utime;
	for (i = 0; i < LOOPS; ++i);
	times(&tms);
	nulltime = tms.tms_utime - starttime; /* Computes overhead of looping */
#endif

	PtrGlbNext = (RecordPtr) malloc(sizeof(RecordType));
	PtrGlb = (RecordPtr) malloc(sizeof(RecordType));
	PtrGlb->PtrComp = PtrGlbNext;
	PtrGlb->Discr = Ident1;
	PtrGlb->EnumComp = Ident3;
	PtrGlb->IntComp = 40;
	strcpy(PtrGlb->StringComp, "DHRYSTONE PROGRAM, SOME STRING");
#ifndef	GOOF
	strcpy(String1Loc, "DHRYSTONE PROGRAM, 1'ST STRING");	/*GOOF*/
#endif
	Array2Glob[8][7] = 10;	/* Was missing in published program */

/*****************
-- Start Timer --
*****************/
#ifdef TIME
	starttime = time( (long *) 0);
#endif
#ifdef TIMES
	times(&tms); starttime = tms.tms_utime;
#endif
	for (i = 0; i < LOOPS; ++i)
	{

		Proc5();
		Proc4();
		IntLoc1 = 2;
		IntLoc2 = 3;
		strcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
		EnumLoc = Ident2;
		BoolGlob = ! Func2(String1Loc, String2Loc);
		while (IntLoc1 < IntLoc2)
		{
			IntLoc3 = 5 * IntLoc1 - IntLoc2;
			Proc7(IntLoc1, IntLoc2, &IntLoc3);
			++IntLoc1;
		}
		Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3);
		Proc1(PtrGlb);
		for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex)
			if (EnumLoc == Func1(CharIndex, 'C'))
				Proc6(Ident1, &EnumLoc);
		IntLoc3 = IntLoc2 * IntLoc1;
		IntLoc2 = IntLoc3 / IntLoc1;
		IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1;
		Proc2(&IntLoc1);
	}

/*****************
-- Stop Timer --
*****************/

#ifdef TIME
	benchtime = time( (long *) 0) - starttime - nulltime;
	printf("Dhrystone(%s) time for %ld passes = %ld\n",
		Version,
		(long) LOOPS, benchtime);
	printf("This machine benchmarks at %ld dhrystones/second\n",
		((long) LOOPS) / benchtime);
#endif
#ifdef TIMES
	times(&tms);
	benchtime = tms.tms_utime - starttime - nulltime;
	printf("Dhrystone(%s) time for %ld passes = %ld\n",
		Version,
		(long) LOOPS, benchtime/HZ);
	printf("This machine benchmarks at %ld dhrystones/second\n",
		((long) LOOPS) * HZ / benchtime);
#endif

}
Beispiel #2
0
Proc0 ()
{
        OneToFifty IntLoc1;
        REG OneToFifty IntLoc2;
        OneToFifty IntLoc3;
        REG char        CharLoc;
        REG char        CharIndex;
        REG Enumeration EnumLoc;
        String30 String1Loc;
        String30 String2Loc;

#define LOOPS 50000
        long    time ();
        long    starttime;
        long    benchtime;
        long    nulltime;
        register unsigned int   i;

        starttime = time (0L);
        for (i = 0; i < LOOPS; ++i);
        nulltime = time (0L) - starttime;

        PtrGlobNext = (RecordPtr) malloc (sizeof (RecordType));
        PtrGlob = (RecordPtr) malloc (sizeof (RecordType));
        PtrGlob -> PtrComp = PtrGlobNext;
        PtrGlob -> Discr = Ident1;
        PtrGlob -> EnumComp = Ident3;
        PtrGlob -> IntComp = 40;
        strcpy (PtrGlob -> StringComp, "DHRYSTONE PROGRAM, SOME STRING");

        starttime = time (0L);
        for (i = 0; i < LOOPS; ++i)
        {
                Proc5 ();
                Proc4 ();
                IntLoc1 = 2;
                IntLoc2 = 3;
                strcpy (String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
                EnumLoc = Ident2;
                BoolGlob =! Func2 (String1Loc, String2Loc);
                while (IntLoc1 < IntLoc2)
                {
                        IntLoc3 = 5 * IntLoc1 - IntLoc2;
                        Proc7 (IntLoc1, IntLoc2, &IntLoc3);
                        ++IntLoc1;
                }
                Proc8 (Array1Glob, Array2Glob, IntLoc1, IntLoc3);
                Proc1 (PtrGlob);
                for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex)
                        if (EnumLoc == Func1 (CharIndex, 'C'))
                                Proc6 (Ident1, &EnumLoc);
                IntLoc3 = IntLoc2 * IntLoc1;
                IntLoc2 = IntLoc3 / IntLoc1;
                IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1;
                Proc2 (&IntLoc1);
        }
        benchtime = time (0L) - starttime - nulltime;
        printf ("Dhrystone time for %ld passes = %ld\n", (long) LOOPS, benchtime);
        printf ("This machine benchmarks at %ld dhrystones/second\n",
                        ((long) LOOPS) / benchtime);
}
Beispiel #3
0
void Proc0()
{
    OneToFifty              IntLoc1;
    OneToFifty              IntLoc2;
    OneToFifty              IntLoc3;
    char                    CharIndex;
    Enumeration             EnumLoc;
    String30                String1Loc;
    String30                String2Loc;
    unsigned long         Loops;
    
    double                  Microseconds,
                            Dhrystones_Per_Second,
                            Vax_Mips;
                      
    double                  startclock;
    double                  benchtime;
        
    register unsigned long  i;

    int         endit, count = 10;
    FILE        *Ap;
    char        general[9][80] = {" "};

 
     /* Initializations */
 
    if ((Ap = fopen("Dhry.txt","a+")) == NULL)
     {
        printf("Can not open Dhry.txt\n\n");
        printf("Press any key\n");
        endit = getch();
        exit(1);
     }
     
/***********************************************************************
 *         Change for compiler and optimisation used                   *
 ***********************************************************************/
       
    PtrGlbNext = (RecordPtr) malloc(sizeof(RecordType));
    PtrGlb = (RecordPtr) malloc(sizeof(RecordType));
    PtrGlb->PtrComp = PtrGlbNext;
    PtrGlb->Discr = Ident1;
    PtrGlb->EnumComp = Ident3;
    PtrGlb->IntComp = 40;
    strcpy(PtrGlb->StringComp, "DHRYSTONE PROGRAM, SOME STRING");
    strcpy(String1Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

    printf ("\n");
    printf ("Dhrystone Benchmark, Version 1.1 (Language: C or C++)\n");
    printf ("\n");

    if (getinput == 0)
     {
         printf ("No run time input data\n\n");
     }
    else
     {
         printf ("With run time input data\n\n");
     }
    
    printf ("Compiler        %s\n", compiler);
    printf ("Optimisation    %s\n", options);
    printf ("\n");
    
    Loops = 5000;

   do
     {

       Loops = Loops * 2;
       count = count - 1;
       Array2Glob[8][7] = 10;

      /*****************
      -- Start Timer --
      *****************/
      
        startclock = dtime();
        
        for (i = 0; i < Loops; ++i)
        {
                Proc5();
                Proc4();
                IntLoc1 = 2;
                IntLoc2 = 3;
                strcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
                EnumLoc = Ident2;
                BoolGlob = ! Func2(String1Loc, String2Loc);
                while (IntLoc1 < IntLoc2)
                {
                        IntLoc3 = 5 * IntLoc1 - IntLoc2;
                        Proc7(IntLoc1, IntLoc2, &IntLoc3);
                        ++IntLoc1;
                }
                Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3);
                Proc1(PtrGlb);
                for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex)
                        if (EnumLoc == Func1(CharIndex, 'C'))
                                Proc6(Ident1, &EnumLoc);
                IntLoc3 = IntLoc2 * IntLoc1;
                IntLoc2 = IntLoc3 / IntLoc1;
                IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1;
                Proc2(&IntLoc1);
        }

        /*****************
        -- Stop Timer --
        *****************/

        benchtime = dtime() - startclock;
        
        printf ("%12.0f runs %6.2f seconds \n",(double) Loops, benchtime);
        if (benchtime > 5)
          {
              count = 0;
          }
        else
          {
              if (benchtime < 0.1)
                {
                   Loops = Loops * 5;
                }
          }
     }   /* calibrate/run do while */
   while (count >0);
   
   for (i = 0; i < Loops; ++i)
        {
           count = count +1;
        }
        
    printf ("\n");
  
    printf ("Array2Glob8/7: ");
    if (Array2Glob[8][7] == count + 10)
                           printf ("O.K.  ");
    else                   printf ("WRONG ");
    printf ("%12.0f\n", (double) Array2Glob[8][7]);
       
    Microseconds = benchtime * 1000000 / (double) Loops;
    Dhrystones_Per_Second = (double) Loops / benchtime;
    Vax_Mips = Dhrystones_Per_Second / 1757.0;
    
    printf ("\n"); 
    printf ("Microseconds for one run through Dhrystone: ");
    printf ("%12.2lf \n", Microseconds);
    printf ("Dhrystones per Second:                      ");
    printf ("%10.0lf \n", Dhrystones_Per_Second);
    printf ("VAX  MIPS rating =                          ");
    printf ("%12.2lf \n",Vax_Mips);
    printf ("\n");

    what_date();
/************************************************************************
 *             Type details of hardware, software etc.                  *
 ************************************************************************/

    if (getinput == 1)
     {

        printf ("Enter the following which will be added with results to file DHRY.TXT\n");
        printf ("When submitting a number of results you need only provide details once\n");
        printf ("but a cross reference such as an abbreviated CPU type would be useful.\n");    
                                    printf ("You can kill (exit or close) the program now and no data will be added.\n\n");
                
        printf ("PC Supplier/model     ? ");
        gets(general[1]);
    
        printf ("CPU chip              ? ");
        gets(general[2]);
    
        printf ("Clock MHz             ? ");
        gets(general[3]);
     
        printf ("Cache size            ? ");
        gets(general[4]);
     
        printf ("Chipset & H/W options ? ");
        gets(general[5]);
      
        printf ("OS/DOS version        ? ");
        gets(general[6]);
        
        printf ("Your name             ? ");
        gets(general[7]);
     
        printf ("Company/Location      ? ");
        gets(general[8]);
     
        printf ("E-mail address        ? ");
        gets(general[0]);
     }
    
/************************************************************************
 *                Add results to output file Dhry.txt                   *
 ************************************************************************/
   fprintf (Ap, "-------------------- -----------------------------------"        
                         "\n");
   fprintf (Ap, "Dhrystone Benchmark  Version 1.1 (Language: C or C++)\n\n");
   fprintf (Ap, "Month run            %d/%d\n", this_month, this_year);   
   fprintf (Ap, "PC model             %s\n", general[1]);
   fprintf (Ap, "CPU                  %s\n", general[2]);
   fprintf (Ap, "Clock MHz            %s\n", general[3]);
   fprintf (Ap, "Cache                %s\n", general[4]);
   fprintf (Ap, "H/W Options          %s\n", general[5]);
   fprintf (Ap, "OS/DOS               %s\n", general[6]);
   fprintf (Ap, "Compiler             %s\n", compiler);
   fprintf (Ap, "OptLevel             %s\n", options);
   fprintf (Ap, "Run by               %s\n", general[7]);
   fprintf (Ap, "From                 %s\n", general[8]);
   fprintf (Ap, "E-Mail address       %s\n\n", general[0]);
   
   fprintf (Ap, "Array2Glob8/7: ");
   if (Array2Glob[8][7] == Loops + 10)
                          fprintf (Ap, "O.K.  ");
   else                   fprintf (Ap, "WRONG ");
   fprintf (Ap, "%10d\n", Array2Glob[8][7]);

   fprintf (Ap, "\n");
   fprintf(Ap,"Microseconds 1 loop:  %12.2lf\n",Microseconds);
   fprintf(Ap,"Dhrystones / second:  %10.0lf\n",Dhrystones_Per_Second);
   fprintf(Ap,"VAX MIPS rating:      %12.2lf\n\n",Vax_Mips);
   fclose(Ap);
                        
    printf ("\n");
    printf ("A new results file will have been created in the same directory as the\n");
    printf (".EXE files if one did not already exist. If you made a mistake on input, \n");
    printf ("you can use a text editor to correct it, delete the results or copy \n");
    printf ("them to a different file name. If you intend to run multiple tests you\n");
    printf ("you may wish to rename DHRY.TXT with a more informative title.\n\n");
    printf ("Please submit feedback and results files as a posting in Section 12\n");
    printf ("or to [email protected]\n\n");

    if (getinput == 1)
     { 
         printf("Press any key to exit\n");
         endit = getch();
         printf ("\nIf this is displayed you must close the window in the normal way\n");    
     }
   
}