Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <math.h>
  3. #include <iostream>
  4. #include <windows.h>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     LARGE_INTEGER timerFrequency, timerStart, timerStop;
  10.     double a, b, x, d, f = 0, t, f1 = 0; double z = 1;
  11.     char s;
  12.     do
  13.     {
  14.         cout << "Enter the ranges of the interval: ";
  15.         cin >> a;
  16.         cin >> b;
  17.         cout << "Enter the increment step: ";
  18.         cin >> d;
  19.         QueryPerformanceFrequency(&timerFrequency);
  20.         QueryPerformanceCounter(&timerStart);
  21.         for (x = a; x < b; x += d)
  22.             f += (x*x) + cos(sqrt(x));
  23.             //f += (cos(x - 1) / sin(x - 1)) * cos(x);
  24.         cout << "f=" << f << endl;
  25.         QueryPerformanceCounter(&timerStop);
  26.         t = (double)(timerStop.QuadPart - timerStart.QuadPart) / (double)timerFrequency.QuadPart;
  27.         printf("Time 1 is %lf seconds.\n", t);
  28.         f = 0;
  29.         _asm finit
  30.         QueryPerformanceFrequency(&timerFrequency);
  31.         QueryPerformanceCounter(&timerStart);
  32.         for (x = a; x < b; x += d)
  33.         {
  34.             _asm {
  35.                 fld x
  36.                 fsqrt
  37.                 fcos
  38.                 fld x
  39.                 fmul x
  40.                 fadd
  41.                 fstp f
  42.  
  43.                 /*fld x
  44.                 fsub z
  45.                 fcos
  46.                 fld x
  47.                 fsub z
  48.                 fsin
  49.                 fdiv
  50.                 fld x
  51.                 fcos
  52.                 fmul
  53.                 fstp f
  54.                 */
  55.             }
  56.             _asm fwait
  57.             f1 += f;
  58.         }
  59.         cout << "f1=" << f1 << endl;
  60.         QueryPerformanceCounter(&timerStop);
  61.         t = (double)(timerStop.QuadPart - timerStart.QuadPart) / (double)timerFrequency.QuadPart;
  62.         printf("Time ASM is %lf seconds.\n", t);
  63.         cout << "Do you want to continue? y/n";
  64.         cin >> s;
  65.     } while (s != 'n');
  66.  
  67.     return 0;
  68.  
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement